Exercises


Exercise 10.1: Starting in a zoomed-in mode

Comment in the last line of the cGameDambuilder::initializeView , rebuild and run the Pop program, and switch to the Game Dambuilder . Note that it is in a zoomed-in mode. Is it still zoomed-in if you switch back to Spacewar? Why not?

Exercise 10.2: A multi-level game

Often people like to write games which have more than one level. To get you started the Pop Framework provides an int _level member of cGame which is initialized to 1 in the constructor (not everything has start counting with 0)! The reset method returns _ level to 1 in case it's changed.

To use level, in your adjustGameParameters you'd look for some trigger condition, such as score > 100, and have a block of code like this:

 if (_level == 1 && score() > 100)  {      _level = 2;      setBackgroundBitmap(IDB_BACKGROUND_LEVEL2);      seedCritters();  } 

An alternate way in which you might switch to level 2 would be to have the player critter trigger the change inside its update method if some condition happened ; for instance if the player were to reach the far right edge of a long Mario-style world.

If you're using levels, your seedCritters should have a switch on _level to change the way in which you seed the world.

If you change the bitmap when you go to the new level you need to remember to change it back when you call reset to return to level 1. This might best be managed by writing a new setLevel accessor for your game to not only set _ level but to set the appropriate bitmap.



Software Engineering and Computer Games
Software Engineering and Computer Games
ISBN: B00406LVDU
EAN: N/A
Year: 2002
Pages: 272

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net