Public Member Functions

CRM32Pro_CTile Class Reference
[MODULE 7: CTile v2.12, tile engine class.]

CTile. More...


Detailed Description

CTile.

Tile engine class.

List of all members.

Public Member Functions

void Clean ()
 Clean and reset the content of current tile.
unsigned char Create (char *filebmp, char *nametile)
 Create a tile from an external image file(BMP/PNG).
unsigned char Create (SDL_Surface *surf, char *nametile)
 Create a tile from a surface.
int Draw (SDL_Surface *dumpto=NULL, int selTS=0)
 Draw a tile in the give surface.
int GetAlpha ()
 Get alpha blending information.
int GetColorKey ()
 Get the current color key.
char * GetName ()
 Get the tile name.
int GetOffset (int *, int *)
 Get X(width) and/or Y(height) for each tile on the tileset.
int GetPosX ()
 Get position X.
int GetPosY ()
 Get position Y.
int GetSizeX (void)
 Get total X(width) size of the tile(or tileset) surface.
int GetSizeY (void)
 Get total Y(height) size of the tile(or tileset) surface.
SDL_Surface * GetSurface ()
 Get the surface of tile.
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).
unsigned char Load (int idDPF, char *name, char *typeblock="TILE2")
 Load a tile from a DPF(using an idDPF).
int Save (int idDPF, char *typeblock="TILE2")
 Save this tile to a DPF(using an idDPF).
int Save (char *fileDPF, char *typeblock="TILE2")
 Save this tile to a DPF(using a filename).
void SetAlpha (int shade)
 Set the alpha per-surface.
void SetColorKey (int CKey)
 Set a colorkey using a packed integer.
void SetColorKey (int r, int g, int b)
 Set a colorkey using RGB values.
void SetName (char *name)
 Set a new name for the tile.
void SetPosition (int x, int y)
 Set a new tile position.
unsigned char SetTileSet (int isTS, int offsetX, int offsetY)
 Convert a single tile on a full tileset and the reverse operation.

Member Function Documentation

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 ( SDL_Surface *  surf,
char *  nametile 
)

Create a tile from a surface.

It supports alpha per pixel surfaces or alpha per surface with/without colorkey.

Parameters:
surf SDL surface to create tile
nametile name for the tile
Returns:
0 Failed
1 Ok
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.

Parameters:
filename Image file name, with its full path, containing the tile
nametile Desired tile name
Returns:
0 Failed
1 Ok
int CRM32Pro_CTile::Draw ( SDL_Surface *  dumpto = NULL,
int  selTS = 0 
)

Draw a tile in the give surface.

Parameters:
dumpto surface to draw the tile, by default is "CRM32Pro.screen", change it if you want to use another surface
selTS it allows to select a desired tile inside the existing tileset. From 1 to number of tiles.
Returns:
0 Failed
1 Ok
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).

Returns:
-1 Failed
From 0(transparent) to 254(almost full opaque) and alpha per-surface enabled
255 Alpha per-surface disabled
256 Alpha per-pixel enabled
int CRM32Pro_CTile::GetColorKey (  ) 

Get the current color key.

To unpack the returned value to independent RGB values, you can use SDL_GetRGB().

Returns:
-1 Colorkey disabled
Any other positive or 0 value, the packed colorkey on an integer.
char * CRM32Pro_CTile::GetName (  ) 

Get the tile name.

Returns:
a pointer to tile name
int CRM32Pro_CTile::GetOffset ( int *  x,
int *  y 
)

Get X(width) and/or Y(height) for each tile on the tileset.

Parameters:
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.
Returns:
0 Failed and it is not a tileset.
1 Ok and it is a tileset.
int CRM32Pro_CTile::GetPosX (  ) 

Get position X.

Returns:
x position of tile
int CRM32Pro_CTile::GetPosY (  ) 

Get position Y.

Returns:
y position of tile
int CRM32Pro_CTile::GetSizeX ( void   ) 

Get total X(width) size of the tile(or tileset) surface.

Returns:
size x of tile surface
int CRM32Pro_CTile::GetSizeY ( void   ) 

Get total Y(height) size of the tile(or tileset) surface.

Returns:
size y of tile surface
SDL_Surface * CRM32Pro_CTile::GetSurface (  ) 

Get the surface of tile.

Returns:
NULL Failed
any other value, a pointer to the SDL surface
unsigned char CRM32Pro_CTile::Load ( int  idDPF,
char *  name,
char *  typeblock = "TILE2" 
)

Load a tile from a DPF(using an idDPF).

Parameters:
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
Returns:
0 Failed
1 Ok
unsigned char CRM32Pro_CTile::Load ( char *  fileDPF,
char *  name,
char *  typeblock = "TILE2" 
)

Load a tile from a DPF(using a filename).

Parameters:
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
Returns:
0 Failed
1 Ok
int CRM32Pro_CTile::Save ( char *  fileDPF,
char *  typeblock = "TILE2" 
)

Save this tile to a DPF(using a filename).

Parameters:
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
Returns:
-1 Tile already exists.
0 Failed.
any other positive value, Ok and packed size of the added tile
int CRM32Pro_CTile::Save ( int  idDPF,
char *  typeblock = "TILE2" 
)

Save this tile to a DPF(using an idDPF).

Parameters:
idDPF ID of the opened DPF.
typeblock by default is "TILE2", don't change it unless you know what you are doing
Returns:
-1 Tile already exists.
0 Failed.
any other positive value, Ok and packed size of the added tile
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).

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
name pointer to the new name. Maximum of 31 characters.
void CRM32Pro_CTile::SetPosition ( int  x,
int  y 
)

Set a new tile position.

Parameters:
x desired new x position
y desired new y position
unsigned char CRM32Pro_CTile::SetTileSet ( int  isTS,
int  offsetX,
int  offsetY 
)

Convert a single tile on a full tileset and the reverse operation.

Parameters:
isTS 0 to convert a full tileset on a single tile. Any other value to convert a single tile on a full tileset
offsetX valid X(width) offset to do the conversion
offsetY valid Y(height) offset to do the conversion
Returns:
0 Failed(it is not a tileset)
1 Ok

The documentation for this class was generated from the following files:
 All Classes Functions Variables