OpenMortal Apocalypse mirror
Sourceforge mirror
SourceForge.net Logo
      News | Info | Characters | Arenas | Screenshots | Forums | Download  
Developer: Making of | Character-HOWTO | AI Design | Submit a Character
Documentation: Main Page | Modules | Class Hierarchy | Class List | File List

CRlePack Class Reference
[Sound and graphics]

CRlePack is an array of images, compressed with runlength encoding. More...

#include <RlePack.h>

List of all members.

Public Member Functions

 CRlePack (const char *a_pcFilename, int a_iNumColors)
 ~CRlePack ()
void Clear ()
int LoadFile (const char *a_pcFilename, int a_iNumColors)
int Count ()
void OffsetSprites (int a_iOffset)
 Offsets the sprites "logical" palette values by the given offset.
void SetTint (TintEnum a_enTint)
void ApplyPalette ()
 Loads the palette of the CRlePack to the gamescreen.
int GetWidth (int a_iIndex)
 Returns the width of a given sprite in pixels.
int GetHeight (int a_iIndex)
 Returns the height of a given sprite in pixels.
void Draw (int a_iIndex, int a_iX, int a_iY, bool a_bFlipped=false)
SDL_Surface * CreateSurface (int a_iIndex, bool a_bFlipped=false)

Private Attributes

CRlePack_Pp


Detailed Description

CRlePack is an array of images, compressed with runlength encoding.

OpenMortal stores the character graphics in CRlePack objects. The reason is simple: CRlePacks give an acceptable tradeoff between memory usage and blitting speed. Also the CRlePack allows the sprites to be draw horizontally flipped, thus saving memory (the mirrored version of the same sprite doesn't need to be stored).

The sprites in the RlePack are always paletted (8 bits per pixel). The size of the palette is between 1 and 256. The RlePack stores two copies of its palette: one is the "base" palette, as it was read from disk, the other is the "tinted" palette. The TintEnum contains values that can be passed to SetTint(). This is used for two things:

CRlePack loads the sprites from a .DAT file in its constructor. If there is an error (e.g. file doesn't exist), the number of sprites loaded will be 0. CRlePack is usually used to store the many frames of a fighter in OpenMortal. It is also used for the 'cast' in the CMainScreenDemo.

CRlePack doesn't concern itself with concepts such as "player" or "doodad", it merely stores the palette and sprites. This part of OpenMortal can be reused in any project with little changes.

See also:
TintEnum


Constructor & Destructor Documentation

CRlePack::CRlePack const char *  a_pcFilename,
int  a_iNumColors
 

CRlePack::~CRlePack  ) 
 


Member Function Documentation

void CRlePack::ApplyPalette  ) 
 

Loads the palette of the CRlePack to the gamescreen.

This only works in 8BPP mode; in other modes the palette is always considered to be loaded, and this is a no-operation.

void CRlePack::Clear  ) 
 

int CRlePack::Count  ) 
 

SDL_Surface * CRlePack::CreateSurface int  a_iIndex,
bool  a_bFlipped = false
 

void CRlePack::Draw int  a_iIndex,
int  a_iX,
int  a_iY,
bool  a_bFlipped = false
 

int CRlePack::GetHeight int  a_iIndex  ) 
 

Returns the height of a given sprite in pixels.

Parameters:
a_iIndex The index of the sprite, 0 <= a_iIndex < Count()

int CRlePack::GetWidth int  a_iIndex  ) 
 

Returns the width of a given sprite in pixels.

Parameters:
a_iIndex The index of the sprite, 0 <= a_iIndex < Count()

int CRlePack::LoadFile const char *  a_pcFilename,
int  a_iNumColors
 

void CRlePack::OffsetSprites int  a_iOffset  ) 
 

Offsets the sprites "logical" palette values by the given offset.

This is only relevant in 8BPP mode; in other color depths this is a no-op.

Explanation: RlePacks have an internal palette which contains up to 256 colors. These colors are always indexed from 0 up. However, if you load two RlePacks with different palettes, the palettes will collide, and one CRlePack will be displayed with an incorrect palette.

To work around this, you can offset one of the sprites palette. For example, you might load an CRlePack with 16 colors, and another with 64 colors. You can offset the second CRlePack by 16 colors; the total effect is that the two RlePacks now use 80 colors of the available 256 colors, the first using colors 0-15, the second using colors 16-79.

void CRlePack::SetTint TintEnum  a_enTint  ) 
 


Member Data Documentation

CRlePack_P* CRlePack::p [private]
 


The documentation for this class was generated from the following files: