Spriteset.c File Reference

Functions

TLN_Spriteset TLN_CreateSpriteset (TLN_Bitmap bitmap, TLN_SpriteData *data, int num_entries)
 Creates a new spriteset. More...
 
bool TLN_SetSpritesetData (TLN_Spriteset spriteset, int entry, TLN_SpriteData *data, void *pixels, int pitch)
 Sets attributes and pixels of a given sprite inside a spriteset. More...
 
TLN_Spriteset TLN_CloneSpriteset (TLN_Spriteset src)
 Creates a duplicate of the specified spriteset and its associated palette. More...
 
bool TLN_DeleteSpriteset (TLN_Spriteset spriteset)
 Deletes the specified spriteset and frees memory. More...
 
bool TLN_GetSpriteInfo (TLN_Spriteset spriteset, int entry, TLN_SpriteInfo *info)
 Query the details about the specified sprite inside a spriteset. More...
 
TLN_Palette TLN_GetSpritesetPalette (TLN_Spriteset spriteset)
 Returns a reference to the palette associated to the specified spriteset. More...
 
int TLN_FindSpritesetSprite (TLN_Spriteset spriteset, char *name)
 Returns a reference to the palette associated to the specified spriteset. More...
 

Detailed Description

Spriteset manager

Function Documentation

TLN_Spriteset TLN_CreateSpriteset ( TLN_Bitmap  bitmap,
TLN_SpriteData data,
int  num_entries 
)

Creates a new spriteset.

Parameters
bitmapBitmap containing the sprite graphics
dataArray of TLN_SpriteData structures with sprite descriptions
num_entriesNumber of entries in data[] array
Returns
Reference to the created spriteset, or NULL if error
See also
TLN_DeleteSpriteset()
bool TLN_SetSpritesetData ( TLN_Spriteset  spriteset,
int  entry,
TLN_SpriteData data,
void *  pixels,
int  pitch 
)

Sets attributes and pixels of a given sprite inside a spriteset.

Parameters
spritesetSpriteset to set the data
entryThe entry index inside the spriteset to modify [0, num_sprites - 1]
dataPointer to a user-provided TLN_SpriteData structure with sprite description
pixelsPointer to source pixel data
pitchNumber of bytes per scanline of the source pixel data
See also
TLN_CreateSpriteset()
TLN_Spriteset TLN_CloneSpriteset ( TLN_Spriteset  src)

Creates a duplicate of the specified spriteset and its associated palette.

Parameters
srcSpriteset to clone
Returns
A reference to the newly cloned spriteset, or NULL if error
See also
TLN_LoadSpriteset()
bool TLN_DeleteSpriteset ( TLN_Spriteset  spriteset)

Deletes the specified spriteset and frees memory.

Parameters
spritesetSpriteset to delete
Remarks
Don't delete a spriteset currently attached to a sprite!
See also
TLN_LoadSpriteset(), TLN_CloneSpriteset()
bool TLN_GetSpriteInfo ( TLN_Spriteset  spriteset,
int  entry,
TLN_SpriteInfo info 
)

Query the details about the specified sprite inside a spriteset.

Parameters
spritesetReference to the spriteset to get info about
entryThe entry index inside the spriteset [0, num_sprites - 1]
infoPointer to application-allocated TLN_SpriteInfo structure that will receive the data
Returns
true if success or false if error
TLN_Palette TLN_GetSpritesetPalette ( TLN_Spriteset  spriteset)

Returns a reference to the palette associated to the specified spriteset.

Parameters
spritesetSpriteset to obtain the palette
Remarks
The palette of a spriteset is created at load time and cannot be modified. When TLN_ConfigSprite function is used to setup a sprite, the palette associated with the specified spriteset is automatically assigned to that sprite, but it can be later replaced with TLN_SetSpritePalette
See also
TLN_SetSpritePalette()
int TLN_FindSpritesetSprite ( TLN_Spriteset  spriteset,
char *  name 
)

Returns a reference to the palette associated to the specified spriteset.

Parameters
spritesetSpriteset where to find the sprite
nameName of the sprite to findo
Returns
sprite index (0 -> num_sprites - 1) if found, or -1 if not found