Game Development Reference
In-Depth Information
Adding the Actors
In this chapter, we will implement the remaining game objects that represent our
actors in the game world. These are the player character bunny head and both the
collectible items: the gold coin and the feather power-up. We will complete the
level loader by adding support for the actor game objects so that these are handled
properly when a level is loaded.
The game will be extended to feature a simple physics simulation that allows any
game object to be moved using physical properties, such as velocity, acceleration,
and friction. In addition, the game logic will also need to detect collisions of the game
objects to trigger certain events. For example, we want the player character to be able
to jump, stand, and walk on a rock (platform), collect items by walking over them,
and lose a life when it falls into the water. The game logic will also include a check to
find out whether the game over condition is met so that the game immediately ends
and a GAME OVER text message is displayed.
In this chapter, we will:
• Implement our game actors
• Create logic for collision detection
• Finish the GUI
Implementing the actor game objects
The gold coin, feather, and bunny head are some of our game objects. Each of our
game objects inherits the AbstractGameObject class. The AbstractGameObject
holds the attributes and functionalities for physics and collision detection.
First, let's make some preparations in AbstractGameObject and add a few
functionalities for our upcoming physics and collision detection code.
Search WWH ::




Custom Search