Press O to move towards the white dot, press X to shoot from the red dot.
I had an idea for a game where you would press a button to accelerate in one direction and press another button to shoot in the opposite direction as you automatically rotate. It ended up being a lot less fun to play than I thought it would be, but there might be some potential here if I flesh it out a bit.
I also ran into some weird runtime errors that I couldn't quite figure out. At first I thought it might be crashing because of the exact position that the bullet hits the target, but I think it might actually be bullets getting removed from the master table of bullets and their indexes getting all janked up. I'll probably have to rewrite the way the table is handled in order to stop this from happening.
Interesting control mechanism - it feels like a game jam restriction 'only two buttons' or the recent 'out of control'.
Re: I also ran into some weird runtime errors ...
I don't think the runtime error I ran into was your bullets table. I could be wrong but, looking at this:
for t=#target,1,-1 do for i=#bullets,1,-1 do if mid(target[t].x-2,bullets[i].x,target[t].x+9)==bullets[i].x and mid(target[t].y-2,bullets[i].y,target[t].y+9)==bullets[i].y then kill_target(t) del(bullets,bullets[i]) end end end |
I think it's because you kill off your target in the inner loop.
Minimal case error reproduction:
- two bullets, one target
- fire first bullet to miss but still be on screen
- fire second bullet to hit, and hit before other goes off screen
--variable tracking of code --not usable code --inner loop: if target[1] etc bullet[2] etc kill_target[1] --function kill_target(1) score+=1 del(target,target[1]) --return control to loop del(bullets,bullets[2]) -- there is one bullets left, bullet[1] --next iteration of inner loop if target[1] etc bullet[1] etc --target[1] does not exist --> crash |
Edit:
You could try break in the inner loop.
Pre-edit I mentioned a probably unnecessary technique of marking the target for destruction. Here I think break will be enough. Click show to see my previous suggestion anyway:
All guesswork; I could be wrong with the above (but hopefully not).
[Please log in to post a comment]