By: Eric C. - April 30, 2022 -
Big Bugs:
Collision:
Out of the many aspects of the code in our game, collision was the most difficult and frustrating aspect to deal with. From the very beginning, it has been a struggle figuring out the most optimal way to do collision, I’ll say this right now that the collision is not perfect whatsoever. But I’ll get to that later. For now, I’m going to talk about what processes I used to debug the collision and at one point, when I had to do a total restart completely re-doing the collision using a totally new method.
In GameMaker, there are two types of collision(that I know of at least), object collision and tile collision. Not until around December/January I was using object collision, where a player object is being checked if it’s colliding with another object acting as a wall. Code wise, the way I did it was I checked in the step event of nova(titan was to be added later), I did the place_meeting condition, which checks if two objects are meeting, or colliding. And with this since the ground is below the object the y parameter for that function would be y - 1, this is because if it was just y the way it works is that nova would freeze it place. This is a fine method of collision, but the problem arises when I tried to put angled slopes into the game. You see, since I physically had to change the angle of the wall object I was editing in the room, the dimensions of that said wall would always stay a rectangle, even though the actual wall is not in all of those dimensions, and with this method of collision the player will collide with those invisible dimensions. Not good. To solve this problem, I did a condition that if the player at x+1 ,y +1 does not collide with the wall, it will move.We also experimented with making the angle of the player the same as the angle of the wall, however it did not look good so id didn’t get put into the game. This new method of collision was buggy. You couldn’t walk down slopes, and with some certain situation it would force you to move up a slope. I got frustrated, so I decided to use a totally new way of collision, tile collision.
A huge shout out to YouTuber Shaun Spalding. With his videos, I learned the majority of the code that I put into the game. The enemy functions, and most importantly the new version of collision, tile collision, I was able to progress in the game at a much faster pace. Without him, our game would be much, much less developed than what it is now. With that being said, I implemented his method of tile collision into our game. It worked. It took a bit of time making sure that it worked for our specific game, but with moving around sloped and general movement, it worked much better than the previous object collision. However, there are some limitations to this method. Since the tile set used for the collision is meant for the ground, floating platforms such as clouds have angles that are upside down. Also, the way the collision works is that it scans the tilset itself to see what height each specific pixel is located at in the tilset. If you try to rotate any of the tiles, it will break the game this way.