Game Development Reference
In-Depth Information
600,400, false, 0x000000);
titleScreen.createDisplayText("Color Drop",
250, new Point(255, 100), screenTextFormat);
titleScreen.createOkButton("Go!",new Point(250,250),100,20,
screenButtonFormat,0xFFFFFF,0x00FF0000,2);
instructionsScreen = new BasicScreen(
FrameWorkStates.STATE_SYSTEM_INSTRUCTIONS, 600,400, false, 0x000000);
instructionsScreen.createDisplayText("Click Colored Blocks",300,
new Point(210,100),screenTextFormat);
instructionsScreen.createOkButton("Play",new Point(250,250),
100, 20, screenButtonFormat, 0xFFFFFF, 0xFF0000, 2);
gameOverScreen = new BasicScreen(
FrameWorkStates.STATE_SYSTEM_GAME_OVER,
600, 400, false, 0x000000);
gameOverScreen.createDisplayText("Game Over",300,
new Point(250, 100), screenTextFormat);
gameOverScreen.createOkButton("Play Again",
new Point(225, 250), 150, 20,
screenButtonFormat,0xFFFFFF,0xFF0000,2);
levelInText = "Level ";
levelInScreen = new BasicScreen(
FrameWorkStates.STATE_SYSTEM_GAME_OVER,
600,400, false, 0x000000);
levelInScreen.createDisplayText(levelInText,300,new Point(275,100),
screenTextFormat);
switchSystemState(FrameWorkStates.STATE_SYSTEM_TITLE);
waitTime= 40;
soundManager.addSound(SOUND_CLICK,new SoundClick());
soundManager.addSound(SOUND_BONUS, new SoundBonus());
soundManager.addSound(SOUND_WIN,new SoundWin());
soundManager.addSound(SOUND_LOSE,new SoundLose());
frameRate = 40;
startTimer();
}
}
}
Creating the Block class
We need to create only a couple extra classes for Color Drop. The first is the
Block
class.
Because
Block
is a fairly complicated class, it's a good idea to get it out of the way first. Since
most of Color Drop is played with colored blocks, this class is also the most important one that we
will create for this game.
First, we create the class and import the proper classes. We are extending this class from
BlitSprite
that we created and put into the game framework in Chapter 7. Recall that
BlitSpite
is a class that itself extends from
Sprite
but is specifically used to both display and animate from
a tile sheet. We are also going to use
TileSheet
class from the game framework.