-
What are sprites?
-
What is sprite animation?
-
What are sprite sheets?
-
Challenges in sprite animation
-
Sprite Files
-
Texture Animation
-
Video Textures
-
Changing between a set of sprites over time, to give the impression of change
-
movement
-
shape change
-
…
-
-
Sprites within sprite sheets
-
selecting the right set of pixels for each sprite
-
-
Animation Cycles
-
selecting the right sprite at the right time
-
smoothing the transitions
-
animation frame rate != render frame rate
-
-
Multiple Animation Cycles
-
when to transition from one cycle to another
-
-
selecting the right set of pixels for each sprite
-
More efficient
-
in general, it is more efficient to have larger images and draw from just part of them
-
fewer texture binds (at the OpenGL level)
-
-
Somehow we have to figure out which area of the sprite sheet correspond to each sprite
-
we NEED more information to do this
-
it might be implicit - i.e. we expect all sprite sheets to conform to some standard
-
we might have that information in another file (or directly in our source code) (or, in theory, embedded in the meta-data of the image)
-
-
animation frame rate != render frame rate
-
selecting the right sprite at the right time
-
smoothing the transitions
-
Our sprite frame rate is frequently lower than our render frame rate
-
Our render frame rate is frequently variable
-
When do we move from one sprite to another?
-
Usually at a fixed rate
-
e.g. 10 sprite frames per second
-
so we need to keep track of real time, and animation time
-
-
How do we represent where in the animation cycle we are?
-
which frame? or a normalised float?
-
DISCUSS …
-
-
the imagery
-
meta-data
What file formats is the image data stored in?
Most image formats are, or can be, used.
-
bmp
-
gif
-
jpg
-
png
-
…
| format | pro | con |
|---|---|---|
|
easy to load |
no transparency; minimal compression |
|
transparency (full/none) |
limited colour depth/palette |
|
high compression; good for real-world scenes |
lossy; has artefacts for some kinds of images (handles hard edges badly); hard to write a loader |
|
transparency (alpha-levels); lossless; compressed |
compression (lossless) isn’t (generally) as good as |
|
transparency (alpha-levels); lossless; compressed; reasonably easy to write a loader |
no web-support |
format for the graphics card |
very fast to load (data direct from file to GPU) |
no web-support |
-
Some formats may be better for PC-only, or Web-only
-
Different file formats for:
-
asset interchange (what your artists work on; what you keep; what you pass from tool to tool)
-
asset packing (for loading into a game)
-
e.g. gltf for 3D (OpenGL)
-
-
-
SDL2 has a simple image loader built-in (
SDL_LoadBMP)-
which loads 24-bit bitmaps into an
SDL_Surface
-
-
We usually want to use other/better image formats
-
SDL2 has a support library SDL_image that can load more formats
-
as of 2016-11-09 a (very active) work-in-progress conan package
-
link:assets/kenny/platformerPack/Player/p1_spritesheet.txt[role=include]
-
If we’re using OpenGL (or DirectX) we can still do sprite animation
-
It is straightforward with texture
-
Each image is a texture
-
the pixel coordinates become UV coordinates
-
SDL’s 2D renderer (usually) uses OpenGL - just like this




