O'Reilly logo

Python Game Programming By Example by Joseph Howse, Alejandro Rodas de Paz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required