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

Hello. Please explain shortly
nourhan Reply
what happens when maximum price is placed above equilibrium price
Christian Reply
the demand curve falls
Ewerton
there will be excess supply
Emmanuel
explain the term : law of demand and it's function
Evacon Reply
law of demand state that the higher the price the lower the quantity demanded and vice versa
Moka
Está correto, sua função também é a de estabilizar o mercado do produto em questão, seu preço, sua produção, etc.
Ewerton
higher******
Umar
what are raw materials
Fatmah Reply
the basic material from which a product is made. "these could be used as raw material"
ADAMU
fatmah raw material, also known as a feedstock, oky is a basic material that is used to produce goods, finished products, energy, or intermediate materials that are feedstock for future finished products. just to make outputs.
ADAMU
oh yeah I got it .. thank you for your help 😊
Fatmah
hello my dear friends
Au
hello
Fatmah
hello
Muhammad
hy
Sortema
Any notes on ppf.?
George
can anyone clarify features of internal efficiency with reference to education
Sortema
in an open economy, the GDP is measured as ?
jacobs Reply
what is Labour of supply.
Eshmel Reply
it is called supply of labour
Emmanuel
it is the total number of those the producer is expected to employ at a given time and at an existing wage rate
Emmanuel
it is a sum number of employees the manufacturer wish to employ in a period of time , and at a given wage rate
Evacon
if the price of yam increases what will happen to demand curve?
Lawal Reply
the demand curve will decrease
Fatmah
with table and diagrametic illustration
Usama Reply
ok
Mustafe
if the price elasticity of demand for a commodity is zero the demand curve is
Aryan Reply
the demand curve is inelastic
Emmanuel
this is because price bring about a lesser change in quantity demanded
Emmanuel
how are we going to draw scale of preference
Achor Reply
how do we identify choice
Achor
how do we identify opportunity cost
Achor
opportunity cost is the forgone alternative. in oder words, it is the sacrificed goods or service for another. thus, the item you did not buy with the resources you have thereby buying another one is called opportunity cost. thanks
John
Opportunity cost considers only the next best alternative to an action, not the entire set of alternatives, and takes into account all of the differences between the two choices.
ADAMU
IAC curve is geueraly
Subham Reply
what are the benefits or tourism?
Maake Reply
please I don't understand the division of labor increase
Dery Reply
Labour increasing according to demand of company or as the condition of profit and standards or weight of working level ,,,,
SHOM
Please can someone help me With the demand of labour.
Eshmel
what are the basic concept of economics
Busanga Reply
end mean and scarcity
Dery
What the term economics?
Nuran Reply
economic is the study of mankind in the ordinary business life
Dery
in a comparison of the stages of meiosis to the stage of mitosis, which stages are unique to meiosis and which stages have the same event in botg meiosis and mitosis
Leah Reply
Researchers demonstrated that the hippocampus functions in memory processing by creating lesions in the hippocampi of rats, which resulted in ________.
Mapo Reply
The formulation of new memories is sometimes called ________, and the process of bringing up old memories is called ________.
Mapo Reply
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