I’m trying to make a galaga remake and I’m not sure how to limit the projectiles on screen to only two.
@Speed9855 good question! after looking at some old galaga footage, seems like there are two limits to how projectiles are fired:
- only two projectiles can be on screen
- there is a minimum time between projectiles firing
for the first constraint, you can check it by comparing the length of the array returned by the array of sprites of kind
block with the limit you want.
for the second constraint, i’d use a variable to keep track of the next time a projectile can be fired at. then compare the current time with that variable to see if a shot can be fired.
together that would look like this:
in the above code, the maximum number of projectiles is 2 and the minimum time between shots is 200ms
Thanks man. I really appreciate it.
Hi @Speed9855! Welcome to the forum!
I do have one more question. How do I make an enemy shoot at me wherever I’m at on the tilemap?