<< Chapter < Page | Chapter >> Page > |
This module is one in a collection of modules designed to teach you about the anatomy of a game engine.
Although the modules in this collection will concentrate on the Java game library named Slick2D, theconcepts involved and the knowledge that you will gain is applicable to different game engines written in different programming languages as well.
The purpose of this module is to teach you how to use objects of the SpriteSheet class and the Animation class to perform simple sprite sheet animation.
I recommend that you open another copy of this module in a separate browser window and use the following links to easily find and view the imagesand listings while you are reading about them.
I will present a program that uses the top row of sprites from the sprite sheetshown in Figure 1 along with a SpriteSheet object and an Animation object to produce an animation of a dog playing. (Note that the overall sprite sheet image is quite small, and the image shown in Figure 1 was enlarged for this presentation.)
Figure 1 . The sprite sheet. |
---|
![]() |
Figure 2 , Figure 3 , and Figure 4 show random screen shots taken while the animation was running.
Figure 2 . Random screen shot of the animation in action. |
---|
![]() |
.
Figure 3 . Random screen shot of the animation in action. |
---|
![]() |
.
Figure 4 . Random screen shot of the animation in action. |
---|
![]() |
Operating characteristics
The program uses only the five sprites in the top row of Figure 1 . The five sprites in the bottom row are ignored. (A program that uses all ten sprites in both rows will be presented in the next module.)
By default, the program displays one cycle of five sprites each second. (Each sprite is displayed for 200 milliseconds, or 0.2 seconds.)
Clock time
As you can see in Figure 4 , clock time in seconds is displayed below the animation.That makes it easy to visually correlate the repetition rate with the clock.
Repetition rate is independent of the frame rate
The time that each image of the dog is displayed is independent of the frame rate. This can be demonstrated bychanging the value of a variable named targetDelta and observing the relationship between the repetition rate and the clock.However, best results are achieved by keeping targetDelta less than the display time for each sprite ( duration ) .
Notification Switch
Would you like to follow the 'Anatomy of a game engine' conversation and receive update notifications?