Over that last few days working on the game has been a learning experience and an exercise in frustration. I finally found a halfway decent running animation to use as a template. It came from the 2600 version of Miner 2049er. Having finally found a decent animation, I dug into setting up a room in code and animating my little player around in it.
It doesn’t look like much and it also doesn’t play like much either. I have to admit that making small games in your spare time can be just as challenging as making PS3 games full time. Bedroom / home-office / garage game programming takes a lot of time. Those of us with children and wives can’t spend days on end creating exotic game engines, so we use the 1-2 hours a day we have at most to create fun small games.
Anyway, I digressed from the ugly monster you see above. My first attempts had the player 2x the size he is above and the walls a single square thickness. I liked the look of that more than this, but efficient collision detection has proven to be elusive no matter the size of the player or the walls. The problem detecting wall collisions is that you really need to ‘look ahead’ to where the player will be on the next frame and check whether of not he/she will be colliding with a wall. Also, for efficiency sake, I am using wall tiles and simple math to check the player’s registration point in the next frame against the tile. If the tile is a wall, then the player should not move. If I move the player first, then check for a hit (which very well might be the way I have to go), I might have strange issues with the player bouncing off the walls repeatedly. Since I have never made a game like this before, I just have to experiment to see what works best.
Click the link here and use the arrow keys to move the player.
Try a Demo
You will see that I was so frustrated with registration point collision detection that I applied a red ‘look ahead’ clip to the player. That clip actually moves first and does a ‘box’ collision detection on the wall. Unfortunately, that seems to not work right either. I highly recommend Jobe Makar’s books on Flash Game Development. In fact, his books are so good, that his ideas can be applied to any kind of small game development, even with programs like Game Maker. I will turn to his book now and use his chapter on tile based worlds to help fix the mess you have just witnessed. Hopefully in my next posting, I will have a demo that works much better. It may no look much better though