Enhancing the Game Sprites

In this game, you demand a lot from your sprites. To handle the new functionality, you need a couple of new methods and variables that all the sprites use. Although only one sprite may actually take advantage of a particular feature, rather than create additional classes, you have every game sprite inherit from SpriteObject because the sprites are largely the same—there is no need to clutter the project.

However, if you expand the game, and you want the boats to be able to fire back, change direction, or spawn smaller boats, then you might want to create a special boat class that embodies these capabilities. Any time a sprite or object uses two or more unique functions, I usually make a new class for it.

Follow these ...

Get Beginning Android Tablet Games Programming 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.