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

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

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