I made a room and called it rm_grass_parent. I changed it's size and added the player to it.
I added some walls and then I tried to test it out. I then encountered a problem. Whenever I would touch a wall my character would just freeze and I wouldn't be able to move him. I'm going to look into the code and see if I did anything wrong.
OK, so I found my problem. I looked back on the video and I realized that he also made the same mistake and that he fixed it later. What was wrong was in the while loops for the horizontal and vertical collisions, instead of "while !place_meeting ..." it was "while place_meeting ...". So I fixed it.
The explanation mark means "not" so whatever you put after its the exact opposite. My code was that if i touched the wall than do the while loop and not if i'm not touching the wall. This caused the game to go in an infinite while loop and freeze the game.
So here is out it looks in the end.
Today I learned how things as small as an explanation mark can completely change your game and now I understand how bug fixing could be the most annoying thing in the world if you have hundreds of lines of code. Like imagine trying to find what was wrong for me in like 300 lines of code, it would take days to find and fix it.
Tomorrow I plan on adding some graphics to my game and adding movement sprites.
ahhh
ReplyDelete