Enemies Attacking the Player

Rob George
1 min readApr 27, 2021

Day 30 — Aspiring Game Creator

2D Game Dev: Galaxy Shooter

Exactly one month in and the base Galaxy Shooter course curriculum finishes with implementing the Enemy Attacking method.

Objectives: Enemies Attack!

Currently, the enemy AI is definitely lacking — this will change! — but what the AI lacks, the speed of the approaching enemy and even deadlier speedy lasers makes them a force to be reckoned with! (Maybe too fast :)

Pseudo Code:

  • Fire Rate & Can Fire variables will keep track of when the enemy can fire.
  • Currently, a small random range will be added to the initial Can Fire so the Player is instantly bombarded at the beginning of each wave.
  • Additionally, a WithinFireRange method will take into account the enemy’s Y Position so it can’t fire too early and won’t be firing just before re-spawning.
  • The enemy’s laser simply moves down at a slightly random speed.

--

--