<< Chapter < Page Chapter >> Page >
Learn to use objects of the Slick2D SpriteSheet class and the Animation class to perform simple spritesheet animation.

Table of contents

Preface

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.

Viewing tip

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.

Figures

  • Figure 1 . The sprite sheet.
  • 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.

Listings

Preview

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.
Missing image.

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.
Missing image.

.

Figure 3 . Random screen shot of the animation in action.
Missing image.

.

Figure 4 . Random screen shot of the animation in action.
Missing image.

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 ) .

Questions & Answers

what is nutrients
Patrick Reply
what are the types of skeleton
Tanyi Reply
endo skeleton and exo skeleton
Faith
or types of skeletons There is exo skeleton found in class insecta Exo skeleton found in phylum chordata and lastly hydrostatic skeleton found mainly in earth worms
Daniel
and hydrostatic skeleton
Godbless
what is life?
Jerson Reply
life is when any living thing breath or respirate.
Lucky
I want to join
Patrick
me too
Favour
me two
Monday
me too
Bengazy
me too
Maggie
I here
Yahaya
Does anybody knows another biology app that brings good understand
Lucky
give an example of a phylum where all members have open circulatory
Omoro Reply
anthropoda
Daniel
phylum Anthropoda
Daniel
how do u change the unit of temperature from degree celsius to degree Fahrenheit
Maggie
what are beneficial effects in industrial
Nnamani Reply
create employment
ibrahim
provide food
ibrahim
pollution
ibrahim
dirty the environment
ibrahim
pollution and lack of knowledge about how to manage waste
Alex
what is gametophyte
Ibrahim Reply
what is biology
Basiru Reply
Biology deals with the study of living organisms and their interactions with each other and the environment.
Quartey
biology simply means the study of living and non-livingthings.
Shamstar
what is the meaning of ubiquitous
Hamziyatu Reply
Under what topic is this question
fred
three branches of biology
Alexander Reply
what is the cell
Olajide Reply
what is life
Olajide
cell is the functional and structural unit of life
Shweta
life is a problem solving entity
Atanga
what is the characteristics of plant cell
Quaku
Describe the process that results in the formation of a tetrad.
Michael Reply
what is biology
Ndukwe Reply
biology is the study of life
Oghenemine
what is biology
Jimmy Reply
the study of life
Hamziyatu
what is the Biosphere?
Kabel Reply
I want to know what classifications of living organisms and their names
Quaku
are classified into plants and animals eukaryotic and prokaryotic cell.
Lokwe
what is biology?
Turabi Reply
what is the meaning of Biologists
Turabi
what is the meaning of Biologists
Turabi
what is the meaning of Biologists
Turabi
are those who are specialized in Biology
Nicode
Is the study of living things,
Kabel
what is the ecosystem?
Kabel
bio mean life logus means study so the study of living things or living organisms is called biology
Faraq
Ecosystem consists of the living organisms in a particular area together with the abiotic factors.
Quartey
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get the best Algebra and trigonometry course in your pocket!





Source:  OpenStax, Anatomy of a game engine. OpenStax CNX. Feb 07, 2013 Download for free at https://legacy.cnx.org/content/col11489/1.13
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Anatomy of a game engine' conversation and receive update notifications?

Ask