Animation
I find it very hard to create animated sprites, but as I mentioned earlier, this could easilybe because I have no skill when it comes to drawing.Animation is perhaps one of the most important elements of a game. Even with a simple game like Tetris, things move—they animate. Having your hero move around the screen in a fixed pose like some kind ofstatue is not much fun to watch. It’s much more exciting to see your characters arms andlegs moving as they walk around the screen.With most modern 3D games, the objectswithin the game (such as bad guys) are 3D models with many triangles used to represent acomplex shape. Movement of these objects is achieved by applying mathematical transformations to the triangles making up the 3D object, causing them to move as required.Some games even employ a skeletal system allowing the animator to simply move the bones of a character and have their body follows as necessary.
Because Sir Lamorak’s Quest is a simple 2D game, we won’t need anything that complex. Instead, we’ll use a simple form of animation that’s very similar to stop-motion animation.This process shows one image (sprite) after another, with the new image (sprite )being in a slightly different position to the last.When pieced together (with code), the images appear to animate as one-image transitions to the next.
By now, you should start to see the benefits of having a sprite sheet.The sprite sheet defines the animation’s different frames; then we use code to load each sprite (or frame) into the animation and display the animated sprites on screen. Figure 2.4 shows a simple sprite sheet containing sprites that can be used within an animation. The first line shows the character running down, the next line running up, then right, and finally left.
Figure 2.4 An animation sprite sheet.