Game Development Reference
In-Depth Information
For Dice Battle, we will create the following classes:
DiceBattle : The main game class for the Dice Battle game. This will extend
com.efg.framework.Game .
DifficultyLevel : This class will define the difficulty levels for the game. Dice Battle has
ten different levels of difficulty.
Character : This class extends from com.efg.framework.BlitSprite . It will be used to
display the player and computer characters on the screen.
Die : We will use this class to represent each die on the screen. This class is much like
Block from the last chapter except that a Die class also has both a value and a color.
CustomEventClickDie : This is a custom event we dispatch when a Die is clicked on the
screen.
GameStates : This class will hold all of the static const values that represent the internal
game states for the Dice Battle game state machine.
Adding game assets to the library
Unlike Color Drop, in which very few assets were required, Dice Battle requires a lot of graphics
and a few extra sounds. A description of both follows.
Adding Graphics for Dice Battle
For Dice Battle, we need two different tile sheets. The first tile sheet contains the different colored
dice we will use in the game. As the levels progress, we will add different colored dice to the
screen. Only dice of the same color can match, so with more colors, it becomes harder to find big
matches of many dice. We could have colored the dice in code to save us the trouble of loading
in three sets, but it is not always easy to get the same effects in code that you can get by just
creating the graphics yourself. Each die is 50
50 pixels, and the tile sheet is shown in Figure 9-
2. The library name for this sheet is diceSheet .
Figure 9-2. Dice tile sheet
The second tile sheet is the set of characters we will use in the game. The first character is the
player. All subsequent characters are the enemies that player will fight in the game. We have
created ten enemies, so there are effectively ten levels in this game. Like other graphics in this
topic, these characters were taken from Ari Feldman's SpriteLib GPL. Each character is 64
64
pixels, and the tile sheet is shown in Figure 9-3. The library name for this sheet is Characters .
Search WWH ::




Custom Search