Apocalypse mirror
Sourceforge mirror |
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 |
#include <RlePack.h>
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_P * | p |
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 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.
|
|
|
|
|
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. |
|
|
|
|
|
|
|
|
|
Returns the height of a given sprite in pixels.
|
|
Returns the width of a given sprite in pixels.
|
|
|
|
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. |
|
|
|
|