Home > Articles > Programming > Games

  • Print
  • + Share This
This chapter is from the book


  1. Why was it necessary to add the SpriteDying() function to the game engine?

  2. The SpriteDying() function is important because it provides a means of carrying out a particular task in response to a sprite being destroyed. Keep in mind that the sprites in the game engine in many ways coexist in their own little world, and at times it can be difficult to interact with them because they are shielded from you. One of the limitations of the game engine prior to this hour was that there was no way to know when a sprite was being destroyed. The SpriteDying() function gives you a glimpse into the "sprite world" and lets you know whenever one of them is being killed. In the Meteor Defense game, this is important because it allows the game to create an explosion whenever a meteor is destroyed.

  3. How does the _iDifficulty global variable control the difficulty level of the Meteor Defense game?

  4. The _iDifficulty global variable is used to determine how often new meteors are added. To make the game harder, you just add meteors more rapidly, which is carried out in the game by decreasing the value of the _iDifficulty variable in response to the score getting higher.

  • + Share This
  • 🔖 Save To Your Account