Hey everyone, Mad Monkey Games here! Today I worked on making the building system a little more coherent and implementing all the basic building materials, but most importantly I started work on enemy AI! The goal of the AI is to get to the player and destroy them no matter what. The enemies will jump over obstacles and stack on top of each other to reach the player.
For those who are interested in some more technical information this is the basics of the AI logic.
The enemy has a direction variable (dir) that is assigned 1 or -1 depending on whether or not the player’s x value is greater or less than the enemy’s x value. 1 being right and -1 being left. The enemy then has a horizontal speed variable (hspd) that is assigned to approach the dir variable. This will result in the enemy moving towards the player, but sense the game is low res pixel art the enemy is much too fast. So, when the hspd variable is approaching dir I simply divide dir by a certain value. In this instance I divide dir by spd_div. spd_div is assigned to randomly choose between 2 and 2.5 this results in some enemies being slower than others. (for those who don’t know the x and y values are to determine a objects position on the screen.)
When the enemy detects a solid object 4 pixels to either its left or right it will jump. It will also jump when the player’s y value is higher than 16 pixels above the enemy and the players x value is not less than 16 pixels to the left and not greater than 16 pixels to the right.
For the blocks I implemented all the basic materials that I came up with.
The enemies destroy the blocks to get through, but each block has a certain amount of durability so it will take enemies longer to get through tougher materials.
That’s basically it. The only other thing is that I made it so you can’t build in mid-air you have to place objects on top of something solid.
Thanks for reading! Comment what you think!
Get Blocks Keep
Leave a comment
Log in with itch.io to leave a comment.