Game Development Reference
In-Depth Information
[Embed(source="../../../../../assets/sound_hitwall.mp3")]
public static const SoundHitWall:Class;
}
}
You must ensure that you have moved the tile sheet and all of the sound assets to the /assets
folder for the project, and placed the folder into the following structure for the Flex SDK (using
Flash Develop):
[source]
[projects]
[driveshesaid]
[flexSDK]
[assets]
[bin]
[obj]
[lib]
[src]
[com]
[efg]
[games]
[driveshesaid]
Remember, the assets folder is at the same level in the directory structure as the src , bin , obj ,
and lib folders. It will not be created automatically; you will need to create it yourself.
Creating the new framework classes
We will be creating some new classes that can be reused in future projects. These classes are
the BasicFrameTimer class, the LookAheadPoint class, the CarBlitSprite class and the
Canvas2D class.
Creating the BasicFrameTimer class
The BasicFrameTimer class is going to be used to create a countdown clock for our game. The
class is very simple but is designed to work with counting up as well as the counting down we
need for this game. It doesn't have any viewable interface, only logical data. For this reason, it
extends the EventDispatcher class.
It does not make use of the getTimer class, because this mixing of time-based logic with frame-
based code would be unfair for players on slower machines. With a real time-based countdown,
the clock would be accurate, but if the game slowed down, the player might not be able to reach
the goal in time. Also, mixing frame-based and time-based code allows cheaters to figure out
methods to slow the game clock but keep the game frame rate running at the correct speed,
which would allow almost unlimited time to complete a level.
What we will do is use a frame-based countdown. The constructor for our game will accept in a
parameter that represents the frame rate our game is set to run at. A single second of time will be
based on this number rather than 1,000 real milliseconds. If the frame rate speeds up or slows
down, our frame-based second will do the same. This will allow players on all machines a fair
attempt at the game.
Search WWH ::




Custom Search