Phase II Progress Report — New enemy– Sniper
In this article, I will discuss the new enemy I have added, the sniper.
The sniper enemy stays at the top of the screen to avoid direct collisions with the player and will shoot accurate bolts at the player and powerups alike.
The sniper is a rare spawn but can cause a lot of pain if not taken out early.
The implementation of the enemy was quite simple. For the movement, I randomly assign a Y height for the enemy.
It then makes its way to this point with a check to see when it arrives.
When it arrives at the correct height it activates another function which makes allows the sniper to strafe between its min and max range on the x-axis.
The enemy casts a ray when it is able to attack. This ray looks for powerups and players and fires a shot when one is found. After every shot, there is a random cool-down period before each next shot.
Now we see it in action.
That's all for now.