60-Smart Enemy Shooting Backwards

In this post, another behavior to the previous enemy, such that when the player is above it, it will shoot up instead of down; once the player is below it, it will shoot down again.

This can be done by comparing the y position of the player and the enemy and set a flag to tell the enemy when to shoot backward or forward.

As the enemy’s laser inherited the laser behavior of the player, we can use the base.Move() of the parent class laser to make the enemy laser travel upwards when shoot backward is switched to true.

--

--