Hi all!
I am trying to implement a very small and simple clone of space invaders.
I am thinking how to implement a nice shoot bullet function but I am struggling with picturing a way to shoot bullets in a nice stream that is always steady so that its pace can be increased picking up right power-ups.
I tried, for example, to count maximum number of bullets on screen and shoot only if < than 5 but when the player shoots, clearly, all the bullets are shot almost at the same time.
Then I thought about storing the bullet starting point and comparing it to the next bullet but since my ship goes also forward and back this way is also wrong...
Can you please suggest me some idea to remove this nasty wall? :)
Thanks for your kind help!
Ps
In case it can be helpful here's the code so far:
https://raw.githubusercontent.com/ltpitt/lua-pico-8-invaders/master/pico-8-invaders.p8



you could use some kind of cooldown timer, for instance along those lines:
gun_timer = 0 gun_cooldown = 10 -- 1 bullet every 10 frames function update() ... if (gun_timer>0) gun_timer-=1 ... end function shoot() ... if (gun_timer==0) then spawn_a_bullet() gun_timer = gun_cooldown end ... end |
[Please log in to post a comment]