Book Image

Python Game Programming By Example

Book Image

Python Game Programming By Example

Overview of this book

Table of Contents (14 chapters)
Python Game Programming By Example
About the Authors
About the Reviewers

Space Invaders design

Before writing our game with cocos2d, we should consider which actors we need to model in order to represent our game entities. In our Space Invaders version, we will use the following classes:

  • PlayerCannon: This is the character controlled by the player. The spacebar is used to shoot, and the horizontal movement is controlled with the right and left arrow keys.

  • Alien: Each one of the descending enemies, with different looks and scores depending on the alien type.

  • AlienColumn: There are columns of five aliens into which every group of aliens is divided.

  • AlienGroup: A whole group of enemies. It moves horizontally or descends uniformly.

  • Shoot: A small projectile launched by the enemies towards the player character.

  • PlayerShoot: A Shoot subclass. It is launched by the player rather than the alien group.

Apart from these classes, we need a custom Layer for the game logic, which will be named GameLayer, and a base class for the logic that is shared among the actors—similar...