Mission Zeno Fighter Chronicles #1

I have started to make a new game, currently called Mission Zeno Fighter. It is going to be a combination of Gravitar, Thrust, Asteroids, and Choplifter (all to various degrees). I started with the code I produced for part 4 of the Atari 7800 Asteroids Tutorial and began making modifications. All of the current graphics are just place holders for testing out concepts. I needed to change out the Asteroid I borrowed from the actual 7800 Asteroids game, so I made a little spiky thing that looks a little Space Duel enemy (all apologies to Owen Rubin ). I also changed the ship to a somewhat ugly gray place-holder and created some crazy cavern walls to fly through.

After making the graphics modifications, I took a look at Keith Peters’ latest book for some ideas on modifying my game loop. While doing that, my buddy, Chris Cutler, came over over to my desk and showed me a new game loop timer that he created in AS3 (using the incredible book, Killer Game Programming In Java as a guide). His loop basically runs the game loop interval one time, then it checks to see how much time it took and re-calculates the game loop for the next round of processing. If processing takes too long, it will update the objects, but not draw them on the screen. If there is processing time left over, it sleeps the code to let garbage collection occur (if needed). INGENIOUS! I haven’t completely delved into his code, but needless to say, it KICKS ASS! I am able to keep my frame rate constant, so no more 30-37FPS on various browsers, I get the full 40 no matter which browser, given that the machine can handle the processing. After Chris was done blowing my mind, I re-cracked open Keith Peters latest and looked through his chapter on game loop timing. Out of that, I added in BitmapData.lock before my updates, BitmapData.unlock after, and threw in an event.updateAfterEvent inside the timer event loop fro good measure. This seems to have made even more improvements, as I can set my movie frame rate to about 10 and still get the 40 updates a second that I am looking for! When I get some nice looking code and more testing done, I’ll write up a tutorial on using it in a real game.

My idea for Mission Zeno Fighter is to have the player flying Asteroids style through caverns on a single screen. The cavern walls are just a giant PNG that I will turn into a BitmapData:

I then added the above to my render function and began to write code to test out collision detection between the ship and the walls. I have to use BitmapData.hitTest() to do this right, and it seems to work great, with one problem. Since I don’t actually know the angle of the wall the the playerShip will hit, I have no idea what angle to use as a reflection for the collision reaction. I’m still racking my brain on this one. My current version is below, and right now it just reflects the ship back in the direction it came, and it works somewhat, but if you play with it for any period of time the seams start to show right away. It is too easy to get stuck and also too easy to trick it into letting you reflect repeatedly through a wall. Anyway, back to the drawing board.

My next attempt will be to create more than one wall bitmap. each one will contain all walls at a particular angle. If I do that, I think I can utilize Keith Peters’ chapter on angle reflections. In any case, if you have any ideas, send them along. Below is the current version so you can experience my failure…

Use the arrow keys to rotate left and right, the up key to thrust (and see how crappy my collision reactions are). You can shoot the ugly blue things by pressing the [z] key. You might have to click on the screen again after clicking the [start] button to get the keyboard to give focus to the movie.

Leave a Reply