Chapter 11. SpritesA game's active entities are often encoded as sprites. A sprite is a moving graphical object, which may represent the player (and so respond to key presses and mouse actions) or may be driven by "intelligent" code in the game. The Sprite class developed in this chapter holds a sprite's position, its speed (coded as incremental steps in the x and y directions), and it uses the image classes (ImagesLoader, ImagesPlayer) from Chapter 6 to manage its graphical presence. Sprite's subclasses add user and environmental interactions and audio effects. The coding of these classes is helped by specifying them first with UML statecharts.
|