i created an enemy that is walking left and right and should fire a projectile if the player gets too close.
the movement of the enemy is controlled by a boolean called "w_left", that toggles if the enemy collides with a sprite called "turn". as long as w_left is true the enemy walkes to the left and if it is false he walkes to the right.
if the enemy is walking to the left (w_left is true) and the player is less than 200px away (enemy.x <= player.x + 200) it should fire a shot. i did the same accordingly for the other side.
if the enemy is walking towards the player everything works smoothly, but if the enemy turns around and faces the other direction it is shooting constanly.
i tried to cover all possible states that could occur but i was not able to figure it out. this drives me mad, i hope someone can help me.
left - A
right - D
jump - L
the black thing around the enemy should symbolise the range.
thanks in advance