Game Development Blog 6

So this is the first of two polish weeks before final!

Now we will focus on making sure that the game actually works and looks good, and most importantly, is hopefully fun to play.

This week, just like the last couple of weeks I have been mostly focusing on enemy AI, more specifically the pathfinding behavior of our AI.

This has proven much more time consuming than I had imagined at the start of this project, but I feel like I have learned a lot of things by doing it.

To recap the last weeks work, I have implemented A-star and made my AI move from point a, to point b, finding the “optimal” route to the destination. This before only worked with the walls of the game, and had very intimidating bugs that caused my enemy to just wander about the place like no one’s business. I worked, but only in specific cases, for example, it could track the player just fine, but if I gave it coordinates on the map it would just freak out.

This week I managed to tie it all together and actually make him wander sensibly around, either just to different rooms randomly, or to target the room that the player was in at the moment.

This was created using a waypoint system, I have a map very similar to our tile map covered in an earlier post, and mark all of the spots that I want as “waypoints”  so that the program can read that and create a list of waypoint to choose from. It then measures the distance between the player and the waypoints to determine the closest one to the player and begin moving there. I intend to put in a system where it takes out the three closest waypoints and chooses a random room to search to make it less punishing for the player.

I have also finally made the AI use a proper “state-machine”, basically so that at any given time he is in a certain “mode” which has unique behaviors, and switches between them sensibly, in our case just based in distance from the player. If he comes to close our enemy will start just target the player and go after him, and if he ever comes close enough, shoot the player.

I also made it so that the pathfinding algorithm no longer tries to cut corners through walls, and added the whole layer of furniture so that it correctly walks around for example a table.

So this week has felt good, finishing things of in polish so that we can take a step back and do the final touches on other places.

About Erik Lindgren

2014  Programming