Core Programming: Enemy Movement

Ryan A
Apr 16, 2021

Well this was a fun challenge to tackle. I decided to add some “controlled randomness” to the movement of the enemies.

Long story short, I’ve created a random chance of some further random conditions of movement per frame, based on where the enemy is in the map. This has worked out quite well and really makes my hack weapon come to life!

Oh — we’re also horizontal now. More screen! :)

This was achieved with a few conditions but mostly a switch statement that lays out the conditions for each rotation change:

I’m sure this could be further developed to be even more random with additional conditions, but for this purpose, it works!

--

--