Essential Guide To Flash Games Book: Chapter 10: A tile-based scrolling driving game

Essential Guide To Flash Games Book: Chapter 10: A tile-based scrolling driving game

I put the finishing touches on the game for chapter 10 this weekend and started writing up the chapter text. It is supposed to be done by now, but the game took me a little longer than I had thought. I originally wrote a tutorial that covered some of this area, but never finished the game. Now that my code and game will be in print, I needed to spend extra time ensuring that I was doing everything as best as I can. It took a little more time than I thought it would. If this had been a one-off game, I could have taken some short-cuts, but the game engine needed to work will all of the levels that anyone could think of (within reason) and to do that took more time than I thought.


Oh well! I will have the chapter complete by the middle of the week. The beginning chapters took care of most of the basics, so in these later chapters I find my self focusing on the new content and not having to (for example) re-hash how to loop back-ward through an array (and why), or why to create listeners with weak references for the 100th time. That makes for a relatively quick written 40 page chapter with a lot of code and explanation for the new and interesting material.

The game is called “Drive She Said”. It is in the Mattel Intellivision Auto Racing / Rally Speedway (Atari and Commodore 8-bit) and Super Cars (ST/Amiga) genre – You drive around a a 2D top-down, scrolling track as fast as you can. I didn’t want to create an actual racing game, but rather more of an arcade adventure game based on driving a car. I ended up with a hybrid of both:

Your task is to collect the hearts around the track before time runs out. You must get to the finish line with enough hearts to make it to the next level (I only have 2 levels right now). There are skulls that will slow you down and clocks that will add time to your timer. The sprites (once again) were taken from Ari Feldman’s Spritelib GPL, but modified by me to suit this particular game. Philosophically, the game represents the Sisyphusian task of keeping an angry girl friend happy. You have done something she doesn’t like and must re-collect all the hearts or she will not take you back. There will always be another level to complete, but the time to do it will get shorter and shorter and the track will get more and more difficult. Eventually time will run out and you will lose the game…don’t we all?

On the technical side, the scrolling world is fed by an XML set of tile sheet data and is output on to a single BitmapData canvas. The scrolling is done with a new Camera2D class that is used to create a display buffer. The buffer is one row and column larger than the canvas (12×12) and the camera orients the output properly by moving to the right location on the 13×13 buffer tile grid before outputting to the 12×12 canvas. The collision detection uses a few tricks (such as look ahead points). The angled tiles made me first think about using Pixel Perfect collision detection, but I went for a more math based model in this game. The car is a child of the BlitSprite class from chapters 6 and 7 modified to include some variables needed for basic car physics and trig.

Anyway, enough talking about it, I need to get back to actually doing it.

More game reviews and a mash-up later this week…

Leave a Reply