The second semester is upon us, and I am back in action. I have rejoined the infotech class, and I have already continued the development of the game. I have also been working over the break, and I feel like I've made a ton of progress. Over the break, I decided to re-code the entire game. Yes, everything; and I'd have to say, the game is much better now than what we had before. I am still working in collaboration with the other guys. Jake is giving me artwork as we go, and I am implementing it into my game. You will see in later screenshots I already have the dragger sprites coded in. I also have the death animation working for it, so I can show that off at a later time.
Today in class, I worked on making the dragger's AI. The goal for it was to be able to track the player, as long as he is in the enemy's sights. I have a few variables involved here that are making this work. There is one that tracks the x value of the player (instead of typing obj_Player.x all over the place), one that tracks the distance to the nearest wall, and one that gives the x value of the nearest wall object. I have been trying to get this to work for weeks now, but I finally figured it out.

To get it to work, I needed to make a separate chunk of code for each situation the player and the enemy could be in. For example, there is one that checks if the player is on the right of the nearest wall, and if the enemy is on the left. If that is true, the enemy (currently) does nothing (I will make it move around randomly on its own soon). There is also one that checks to see if the player and the enemy are on the same side of the wall. If they are, the enemy tracks towards the player and tries to kill him. There are different instances of this for if the player is on the left or right of the wall, as well as if the enemy is on the left or right of the wall. There are two copies of that; one that works based on if the enemy is a distance of 400 away from the nearest wall, and one that works if the enemy is within a distance of 400 from the nearest instance. That way, the enemy won't get stuck in between the walls, but will still detect if there is a wall between it and the player. I am going to make the distance of 400 much shorter however, as it may cause some problems in the future for making small rooms and pit traps and whatnot that are smaller than 400 wide.
 |
Notable in the screenshot is that the enemy is getting stuck to the roof when it jumps into it. This will also be fixed in the future as I just need to make a simple fix by using some simple instance_nearest calculations.
if instance_nearest(obj_Floor).y>y{ collision=0; y+=1; } |
Now that the AI is done, all I need to do is actually make the enemy do something while it is not tracking the player. I also got a suggestion from Jake to slow down the rate at which the enemy is able to jump. Right now, it is just jumping again as soon as it touches back down on the ground. Tomorrow in class I will be working on the random movement. I think I have a text file of a test one that I wrote out. Since I never got the AI to work properly, I never got to test the random movement code. I'll try implementing that and seeing if it works. If I remember as well, I'll try to limit the jumping of the enemy. I also need to fix the sprites for the dragger so that when it is stopped, the walking animation does not play. I also will have some sprites for the player to be putting in soon as Jake finishes them.