CRM32Pro SDK
v5.22
|
CTile. More...
CTile.
Tile engine class.
Public Member Functions | |
void | Clean () |
Clean and reset the content of current tile. More... | |
unsigned char | Create (char *filebmp, char *nametile) |
Create a tile from an external image file(BMP/PNG) More... | |
unsigned char | Create (SDL_Surface *surf, char *nametile) |
Create a tile from a surface. More... | |
int | Draw (SDL_Surface *dumpto=NULL, int iTID=0) |
Draw a tile in a destination surface. More... | |
int | GetAlpha () |
Get alpha blending information. More... | |
int | GetColorKey () |
Get the current color key. More... | |
char * | GetName () |
Get the tile name. More... | |
int | GetOffset (int *, int *) |
Get X(width) and/or Y(height) for each tile on the tileset. More... | |
int | GetPosX () |
Get position X. More... | |
int | GetPosY () |
Get position Y. More... | |
int | GetSizeX (void) |
Get total X(width) size of the tile(or tileset) surface. More... | |
int | GetSizeY (void) |
Get total Y(height) size of the tile(or tileset) surface. More... | |
SDL_Surface * | GetSurface () |
Get the surface of tile. More... | |
void | Info () |
Print a lot of useful tile information. Very useful for debugging purposes. | |
unsigned char | Load (char *fileDPF, char *name, char *typeblock="TILE2") |
Load a tile from a DPF(using a filename) More... | |
unsigned char | Load (int idDPF, char *name, char *typeblock="TILE2") |
Load a tile from a DPF(using an idDPF) More... | |
int | Save (char *fileDPF, char *typeblock="TILE2") |
Save this tile to a DPF(using a filename) More... | |
int | Save (int idDPF, char *typeblock="TILE2") |
Save this tile to a DPF(using an idDPF) More... | |
void | SetAlpha (int shade) |
Set the alpha per-surface. More... | |
void | SetColorKey (int r, int g, int b) |
Set a colorkey using RGB values. More... | |
void | SetColorKey (int CKey) |
Set a colorkey using a packed integer. More... | |
void | SetName (char *name) |
Set a new name for the tile. More... | |
void | SetPosition (int x, int y) |
Set a new tile position. More... | |
unsigned char | SetTileSet (int isTS, int iWidthOffset, int iHeightOffset) |
Convert a single tile on a full tileset and the reverse operation. More... | |
void CRM32Pro_CTile::Clean | ( | ) |
Clean and reset the content of current tile.
Useful to reuse the tile object with another content without use 'delete' and 'new' operators.
unsigned char CRM32Pro_CTile::Create | ( | char * | filename, |
char * | nametile | ||
) |
Create a tile from an external image file(BMP/PNG)
By default, alpha per surface and colorkey are disabled. If you want to use it, you must set it after the tile creation.
But if your PNG already has alpha per-pixel information, it will be automatically used.
filename | Image file name, with its full path, containing the tile |
nametile | Desired tile name |
unsigned char CRM32Pro_CTile::Create | ( | SDL_Surface * | surf, |
char * | nametile | ||
) |
Create a tile from a surface.
It supports alpha per pixel surfaces or alpha per surface with/without colorkey.
surf | SDL surface to create tile |
nametile | name for the tile |
int CRM32Pro_CTile::Draw | ( | SDL_Surface * | dumpto = NULL , |
int | iTID = 0 |
||
) |
Draw a tile in a destination surface.
dumpto | destination surface, by default is CRM32Pro.screen. |
iTID | tile id from the current tileset. From 1 to number of tiles. You can OR'ed it with any (but only one) TILEFFECT_xxx flag for drawing the tile using special effects. Bits 32,31 and 30 are reserved for these effects. |
int CRM32Pro_CTile::GetAlpha | ( | ) |
Get alpha blending information.
To extend the information about the alpha blending, you can read How SDL Alpha works (based on SDL documentation).
int CRM32Pro_CTile::GetColorKey | ( | ) |
Get the current color key.
To unpack the returned value to independent RGB values, you can use SDL_GetRGB().
char * CRM32Pro_CTile::GetName | ( | ) |
Get the tile name.
int CRM32Pro_CTile::GetOffset | ( | int * | x, |
int * | y | ||
) |
Get X(width) and/or Y(height) for each tile on the tileset.
x | pointer to an integer to store the width for each frame. NULL if you do not want to query it. |
y | pointer to an integer to store the height for each frame. NULL if you do not want to query it. |
int CRM32Pro_CTile::GetPosX | ( | ) |
Get position X.
int CRM32Pro_CTile::GetPosY | ( | ) |
Get position Y.
int CRM32Pro_CTile::GetSizeX | ( | void | ) |
Get total X(width) size of the tile(or tileset) surface.
int CRM32Pro_CTile::GetSizeY | ( | void | ) |
Get total Y(height) size of the tile(or tileset) surface.
SDL_Surface * CRM32Pro_CTile::GetSurface | ( | ) |
Get the surface of tile.
unsigned char CRM32Pro_CTile::Load | ( | char * | fileDPF, |
char * | name, | ||
char * | typeblock = "TILE2" |
||
) |
Load a tile from a DPF(using a filename)
fileDPF | name and optional path of a DPF that contains the tile |
name | name of tile |
typeblock | by default is "TILE2", don't change it unless you know what you are doing |
unsigned char CRM32Pro_CTile::Load | ( | int | idDPF, |
char * | name, | ||
char * | typeblock = "TILE2" |
||
) |
Load a tile from a DPF(using an idDPF)
idDPF | ID of the opened DPF |
name | name of tile |
typeblock | by default is "TILE2", don't change it unless you know what you are doing |
int CRM32Pro_CTile::Save | ( | char * | fileDPF, |
char * | typeblock = "TILE2" |
||
) |
Save this tile to a DPF(using a filename)
fileDPF | name and optional path of a DPF to store this tile. |
typeblock | by default is "TILE2", don't change it unless you know what you are doing |
int CRM32Pro_CTile::Save | ( | int | idDPF, |
char * | typeblock = "TILE2" |
||
) |
Save this tile to a DPF(using an idDPF)
idDPF | ID of the opened DPF. |
typeblock | by default is "TILE2", don't change it unless you know what you are doing |
void CRM32Pro_CTile::SetAlpha | ( | int | shade | ) |
Set the alpha per-surface.
A surface with enabled alpha blending(per-pixel or per-surface) will be never created on video memory if alpha blending is not supported by the hardware. Right now, only glSDL supports it.
With per-pixel alpha, per-surface alpha is useless, so any attempt to activate it will be ignored.
Note that enabling and disabling the alpha blending on the execution time could slowdown your graphic performance.
To extend the information about the alpha blending, you can read How SDL Alpha works (based on SDL documentation).
shade | integer from 0(transparent) to 254(almost full opaque) to enable the per-surface alpha or 255(full opaque) to disable it. |
void CRM32Pro_CTile::SetColorKey | ( | int | r, |
int | g, | ||
int | b | ||
) |
Set a colorkey using RGB values.
With alpha per pixel, colorkey is useless.
In OpenGL mode (glSDL), changing the colorkey after loading/creating the tile could slowdown your graphic performance.
r | red component (0-255). -1 to disable the colorkey. |
g | green component (0-255). -1 to disable the colorkey. |
b | blue component (0-255). -1 to disable the colorkey. |
void CRM32Pro_CTile::SetColorKey | ( | int | CKey | ) |
Set a colorkey using a packed integer.
To pack the integer with RGB values, you can use SDL_MapRGB().
With alpha per pixel, colorkey is useless.
In OpenGL mode (glSDL), changing the colorkey after loading/creating the tile could slowdown your graphic performance.
CKey | packed integer with colorkey. You can also use -1 to disable the colorkey. |
void CRM32Pro_CTile::SetName | ( | char * | name | ) |
Set a new name for the tile.
name | pointer to the new name. Maximum of 31 characters. |
void CRM32Pro_CTile::SetPosition | ( | int | x, |
int | y | ||
) |
Set a new tile position.
x | desired new x position |
y | desired new y position |
unsigned char CRM32Pro_CTile::SetTileSet | ( | int | isTS, |
int | iWidthOffset, | ||
int | iHeightOffset | ||
) |
Convert a single tile on a full tileset and the reverse operation.
Since v5.21, the conversion allows to have non-exact offset division, the remainder parts of the image will not be used.
isTS | 0 to convert a full tileset on a single tile. Any other value to convert a single tile on a full tileset |
iWidthOffset | width offset to do the conversion. Negative and 0 values are converted to 1. |
iHeightOffset | height offset to do the conversion. Negative and 0 values are converted to 1. |