The animation plays in mid air which is kind of weird. I found the secret, and I DIDN'T USE THE CODE TO HELP.
But here are some comments on your code. You forgot to set the gamestate back to level 1 so we instantly start on level 4. That also showed me you're using separate gamestates for each different level. Though that is something you can do, an alternative would be to make a single game gamestate and just switch levels in between that. It would remove the need to create new ones each level, and would probably speed up the development process. Just a quick suggestion.
Another thing is you don't seem to know what a numeric for loop is. So let me teach you.
A numeric for loop simply loops through numbers one at a time from a start point to an end point using whatever step you wanted. An example:
The first value (1) is the starting point and the second value (100) is the end point. So that would print 1 through 100. Another example:
That -1 is the step, so it would go through all the numbers 1-100 backwards. You can supply anything you want for the start, end and step (they can be variables as well like for i = start, stop, step do)
So now this can be used in some clever ways.
Code: Select all
function bullet_counter_draw()
if P_bullets == 1 then
g.draw(B_pic,32,26, math.rad(-90),4,4)
end
if P_bullets == 2 then
g.draw(B_pic,32,26, math.rad(-90),4,4)
g.draw(B_pic,64,26, math.rad(-90),4,4)
end
if P_bullets == 3 then
g.draw(B_pic,32,26, math.rad(-90),4,4)
g.draw(B_pic,64,26, math.rad(-90),4,4)
g.draw(B_pic,96,26, math.rad(-90),4,4)
end
if P_bullets == 4 then
g.draw(B_pic,32,26, math.rad(-90),4,4)
g.draw(B_pic,64,26, math.rad(-90),4,4)
g.draw(B_pic,96,26, math.rad(-90),4,4)
g.draw(B_pic,128,26, math.rad(-90),4,4)
end
if P_bullets == 5 then
g.draw(B_pic,32,26, math.rad(-90),4,4)
g.draw(B_pic,64,26, math.rad(-90),4,4)
g.draw(B_pic,96,26, math.rad(-90),4,4)
g.draw(B_pic,128,26, math.rad(-90),4,4)
g.draw(B_pic,160,26, math.rad(-90),4,4)
end
if P_bullets == 6 then
g.draw(B_pic,32,26, math.rad(-90),4,4)
g.draw(B_pic,64,26, math.rad(-90),4,4)
g.draw(B_pic,96,26, math.rad(-90),4,4)
g.draw(B_pic,128,26, math.rad(-90),4,4)
g.draw(B_pic,160,26, math.rad(-90),4,4)
g.draw(B_pic,192,26, math.rad(-90),4,4)
end
if P_bullets == 7 then
g.draw(B_pic,32,26, math.rad(-90),4,4)
g.draw(B_pic,64,26, math.rad(-90),4,4)
g.draw(B_pic,96,26, math.rad(-90),4,4)
g.draw(B_pic,128,26, math.rad(-90),4,4)
g.draw(B_pic,160,26, math.rad(-90),4,4)
g.draw(B_pic,192,26, math.rad(-90),4,4)
g.draw(B_pic,224,26, math.rad(-90),4,4)
end
if P_bullets == 8 then
g.draw(B_pic,32,26, math.rad(-90),4,4)
g.draw(B_pic,64,26, math.rad(-90),4,4)
g.draw(B_pic,96,26, math.rad(-90),4,4)
g.draw(B_pic,128,26, math.rad(-90),4,4)
g.draw(B_pic,160,26, math.rad(-90),4,4)
g.draw(B_pic,192,26, math.rad(-90),4,4)
g.draw(B_pic,224,26, math.rad(-90),4,4)
g.draw(B_pic,256,26, math.rad(-90),4,4)
end
end
Yeah these things can be pretty useful.