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 that the on_exit
method is called when a node is removed, so you will be overriding it to inform its corresponding column. Note that a reference to the column is passed to the __init__
method. We could have implemented the same functionality...