# Enemy Sprite firing back... How to do it?

I’m trying to create an enemy sprite that fires projectiles. Someone want to help me out? Thanks in advance.

How would you want them to fire projectiles - in the direction of the player, or just in a given direction (e.g. space aliens can fire lasers downwards at random).

Either way, it will be something that you likely want to apply to all sprites of a given type (like enemy) - to do that, you can use `array of sprites of kind` from the `arrays` category of the toolbox (under `Advanced`) to create an array of all the currently existing sprites of that kind.

This sample has enemies that move across the screen while firing projectiles downwards.

(if you want them to actually be fired in the direction of the player, you will need to do some math based off the `x` and `y` positions of the two sprites)

2 Likes

Thanks. I just figured out another way to do it, but I might give this a try as well to see which one works best. Sometimes doing it a different way makes the game flow better. Thanks again for the answer. I like it. It makes sense. I’m making a tank game in a platformer format. I need the enemy tanks to fire in a straight line… no targeting necessary. But I might use the targeting idea to create a boss at the end of a level. Thanks. I hadn’t even considered it.

No problem! If you have any more questions, we’re happy to answer! (and we’d love to see the game when it is completed!)

Absolutely. You’ll see it for sure… if I can get it like I want it.

precisely that last thing you mention is what is difficult for me to understand, the mathematical part, which moves at random and launches projectiles towards the enemy, if you could explain me I would be very grateful

[image]