Cleaning Up Add Extending Enemy Behaviour


Two major things in this most recent update. 

First, enemy pathing is now blocking. Enemies could previously move onto the same tile and overlap each other. This functionally has no benefit I can (currently) see, so it is now prevented. I am iterating through all the enemies in the level. They pick their next tile, based on the shortest path to the player, and block that tile. At the same time, they unblock their current tile. This way the next enemy in the array can't choose the same destination tile, but can choose a currently occupied tile that will be cleared. This allows enemies to stack up in a line, but never over top of each other.

The new behaviour does mean that if an enemy next move blocks another enemy's path to the player, it will choose to not move at all, including to where the blocking enemy is currently. Something I'll need to consider if I want to modify in the future. Shouldn't be difficult to change, but may not be relevant or worth the effort. I'll wait until I've got a proper use case for it.

The second is a bit of an edge case. 



When the player occupies any of the eight tiles surrounding an enemy, this triggers enemy "splode" and player death. That included the above scenario, where the enemy didn't have a navigation path to the player, but is within the eight tile bounding box. It has been updated now to check if the connecting tiles between the player and enemy when they are on a connected diagonal are blocking. If so, "no splode".

Still a little bit of enemy behaviour work still to do, but that's it for today.

Files

game.zip Play in browser
2 days ago

Leave a comment

Log in with itch.io to leave a comment.