The Animation Framework


Class Diagrams for AlienTiles

Figure 13-7 shows a simplified set of class diagrams for AlienTiles. The audio and image classes (e.g., MidisLoader, ClipsLoader, and ImagesLoader) have been edited away, and the less important links between the remaining classes have been pruned back for clarity.

Figure 13-7. AlienTiles classes diagram (simplified)


The AlienTiles JFrame and the AlienTilesPanel JPanel implement the windowed animation framework introduced in Chapters 2 and 3, BugRunner of Chapter 11, and JumpingJack of Chapter 12 use the same technique.


Pausing, resuming, and quitting are controlled via AlienTiles' window listener methods. The frame rate is set to 40 FPS, which is still too fast for the alien sprites; they are slowed down further by code in AlienQuadSprite and AlienAStarSprite.

WorldDisplay displays the surface image and the blocks, pickups, and sprites resting on the surface. The tile coordinates for the entities are stored in a WorldItems object, using a TileOccupier object for each one. WorldDisplay acts as a communication layer between the player and the aliens.

Figure 13-7 includes a small sprite inheritance hierarchy, rooted at Sprite, which is shown on its own in Figure 13-8.

Figure 13-8. The sprite hierarchy in AlienTiles


Most of the methods in Sprite are extended or overridden by tile-related methods in its subclasses. Tile coordinates are utilized by the game most of the time, supported by methods in TiledSprite though a sprite's pixel location (maintained by Sprite) is needed when it's being drawn to the screen. The player is represented by a PlayerSprite object.

AlienAStarSprite uses the A* JWS (Java Web Start):JWS and other libraries algorithm, which necessitates the TilesPriQueue and TilesList data structure classes; they maintain sequences of TileNode objects.

The code for the AlienTiles game can be found in the AlienTiles/ directory.




Killer Game Programming in Java
Killer Game Programming in Java
ISBN: 0596007302
EAN: 2147483647
Year: 2006
Pages: 340

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net