Files | |
file | blitter.cpp |
Blitting algorithms for the SpriteManager. | |
file | sprite.cpp |
Function implementations for Sprite. | |
file | sprite.h |
Class definition for Sprite. | |
file | spriteloader.cpp |
Function implementations for SpriteLoader. | |
file | spriteloader.h |
Class definition for SpriteLoader. | |
file | spritemanager.cpp |
Function implementations for SpriteManager. | |
file | spritemanager.h |
Class definition for SpriteManager. | |
Classes | |
class | Sprite |
The basic Sprite class itself. More... | |
class | SpriteLoader |
Class to handle loading all necessary data for a sprite. More... | |
class | SpriteManager |
Class to manage movement, collision, and drawing of sprites. More... | |
Sprite flags | |
Functions of the various sprite flags | |
#define | SPRITE_NONE 0x0000 |
No flags. | |
#define | SPRITE_WAIT 0x0001 |
Sprite is waiting for first draw or removal from list. | |
#define | SPRITE_MOVED 0x0002 |
Sprite needs redraw. | |
#define | SPRITE_EXPIRED 0x0004 |
Sprite needs removal from list. | |
#define | SPRITE_DELETEABLE 0x0008 |
Sprite can be freed from mem upon removal from list. | |
#define | SPRITE_OWNSURFACE 0x0010 |
Sprite owns aka can free the contained SDL_surface. | |
#define | SPRITE_OWNBITMASK 0x0020 |
Sprite owns aka can free the contained bitmasks. | |
SpriteManager flags | |
Flags to control the behavior of SpriteManager | |
#define | MAX_RECTS 512 |
Maximum number of rectangles in draw-stack. | |
#define | SM_NONE 0x0000 |
No flags. | |
#define | SM_RUNNING 0x0001 |
SpriteManager is running. | |
#define | SM_TOTALREDRAW 0x0002 |
SpriteManager needs to totally redraw screen. | |
#define | SM_PAUSED 0x0004 |
SpriteManager is paused. | |
#define | SM_OWNBG 0x0008 |
SpriteManager owns the background surface. | |
#define | SM_DOUBLEBUF 0x0010 |
Spritemanager must do full screen flips. | |
Defines | |
#define | COL_LAYER(x) (0xff&(1<<x)) |
Converts a collision layer to a collision mask. | |
#define | SLASH "/" |
Most sane systems use forward-slashes. | |
Typedefs | |
typedef Uint16 | SpriteFlag |
Type used for sprite status flag. | |
typedef Uint8 | ColType |
Type used for collision layer. | |
Enumerations | |
enum | SMRun_Return { SMRUN_OK = 0, SMRUN_TIMESTEP } |
Return values for SpriteManager::Run(). More... | |
Functions | |
SDL_Surface * | LoadConvertBMP (const char *fname, Uint8 tr, Uint8 tg, Uint8 tb) |
Loads an image and converts it to screen parameters. | |
bitmask * | MakeBitMask (SDL_Surface *surf, Rect rect) |
Converts selected portion of image into collision bitmask. | |
char * | SprMakePath (const char *filename, const char *path, char *buf) |
Function to assemble a full path from a path and filename. |
Sounds really complicated, but it's not. Basically, you have a SpriteManager object, which contains a bunch of Sprite objects. The SpriteManager runs a game loop, which continues looping until an SDL quit message is recieved; this loop reads events, moves sprites, and redraws the screen.
You need not concern yourself with the low-level handling of movement, events, or collision - Sprite and SpriteManager handle all of these. To create custom sprite behavior, simply overload Sprite::Update() and do as you wish. There are many simple overloadable operatires in SpriteManager as well, take a look.
And for creating the sprites, SpriteLoader helps a LOT, by using external configuration files to define certain sprite parameters(like graphics and collision) instead of needing to hardcode them - it takes the mess out of sight unless it needs to be seen, and allows you to modify sprite parameters and graphics significantly without needing to recompile.
|
Prevents a potential race condition; if a sprite's Update() member causes more sprites to be added to a list of sprites, which cause more, and so forth. This flag prevents brand-new sprites from being considered for collision and movement until the NEXT frame. Definition at line 90 of file sprite.h. Referenced by Sprite::Init_Flags(), SpriteManager::Move(), and Sprite::New(). |
|
Definition at line 61 of file spritemanager.h. Referenced by SpriteManager::Run(). |
|
Loads an image file and converts it to local format. Definition at line 390 of file sprite.cpp. Referenced by SpriteLoader::Load(), and SpriteManager::SpriteManager(). |
|
Turns a portion of an image to a collision mask. Needs SDL_SRCCOLORKEY to be set. Definition at line 347 of file sprite.cpp. References getpixel(). Referenced by Sprite::Init_Bitmask(), and SpriteLoader::Load(). |
Here is the call graph for this function:
|
Attempts to assemble a full path from a relative offset and a filename. Definition at line 419 of file spriteloader.cpp. References lastchar(), and SLASH. Referenced by SpriteLoader::Load(). |
Here is the call graph for this function: