Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Python Game Programming By Example

You're reading from   Python Game Programming By Example A pragmatic guide for developing your own games with Python

Arrow left icon
Product type Paperback
Published in Sep 2015
Publisher
ISBN-13 9781785281532
Length 230 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Toc

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

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime