Invaders!

There are three classes used to represent our invaders: Alien, AlienColumn, and AlienGroup.

Out of these classes, only Alien inherits from Actor because it is the only entity that is drawn and collides with other objects. Instead of a static image, the sprite will be a basic animation wherein each image will be shown for 0.5 seconds. This is achieved by loading an ImageGrid and creating an Animation from this sprite grid. Since these classes belong to the pyglet.image module, we need to import them first.

Another function of our aliens will be notifying its column that the object has been removed. Thanks to this, the column of aliens knows what the bottom one is and starts shooting from its position.

You learned from the CocosNode reference ...

Get Python Game Programming By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.