CRM64Pro GDK v0.13.0
A free cross-platform game development kit built on top of SDL 3.0
Loading...
Searching...
No Matches
TileEngine MapData extension

Description

Data definition classes for TileEngine layer management v3.00 (May 2024).

Overview

The TileEngine MapData module provides the TE_MapData class that implements all required methods for managing map layer data. This class serves as the foundation for layer updating and rendering within the TileEngine system.

Key features

  • Layer data management: Core data structures for tile-based layer content
  • Update integration: Methods for layer update cycle integration
  • Render integration: Methods for layer render cycle integration
  • Extensible design: Base class for custom map data implementations

TE_MapData class

PurposeImplements all required methods for managing a map layer
Update cycleProvides data for layer update operations
Render cycleProvides data for layer rendering operations
ExtensibilityCan be extended via C++ inheritance for custom map data

Integration with TileEngine

Parent moduleTileEngine Core module
UsageUsed by TileEngine objects for layer data operations

Best practices

  • Extend TE_MapData when you need custom data structures beyond standard tile maps
  • Override update methods to add custom per-frame logic to your map layers
  • Override render methods to customize layer rendering behavior
  • Keep custom map data lightweight to maintain rendering performance
  • Use in conjunction with the TileEngine Core module for complete tile-based game development

Classes

class  CRM64Pro::TE_MapData
 MapData class. More...

Functions

template<typename T>
T ** CRM64Pro::TE_MapData::create2DArray (Sint32 height, Sint32 width)
 Template: dynamic 2D array of a given data type.
template<typename T>
Sint32 CRM64Pro::TE_MapData::free2DArray (T **Array)
 Template: delete a dynamic 2D array.
 CRM64Pro::TE_MapData::TE_MapData (Sint32 height, Sint32 width)
 MapData constructor.
Sint32 CRM64Pro::TE_MapData::getCellWidth ()
 Get cell width.
Sint32 CRM64Pro::TE_MapData::setCellWidth (Sint32 size)
 Set cell width.
Sint32 CRM64Pro::TE_MapData::getCellHeight ()
 Get cell height.
Sint32 CRM64Pro::TE_MapData::setCellHeight (Sint32 size)
 Set tile height.
Sint32 CRM64Pro::TE_MapData::getWidth ()
 Get map width.
Sint32 CRM64Pro::TE_MapData::getHeight ()
 Get map height.
Sint32 CRM64Pro::TE_MapData::create (Sint32 height, Sint32 width, Uint32 value=0)
 Create the 2D array for the tiles allocation.
Sint32 CRM64Pro::TE_MapData::free ()
 Delete the 2D array.
Sint32 CRM64Pro::TE_MapData::setValue (Sint32 y, Sint32 x, Uint32 value)
 Set arbitrary values on 2D array.
Sint32 CRM64Pro::TE_MapData::clone (TE_MapData *dest)
 Copy the current values of the 2D array iTilemap to the given MapData.
Sint32 CRM64Pro::TE_MapData::check ()
 Map validation.
Sint32 CRM64Pro::TE_MapData::info (Sint8 bTilesetReady, eLogMessageLevel LML)
 Request MapData object information.
Sint32 CRM64Pro::TE_MapData::saveToXMLNode (Sint32 idXML)
 Save the mapdata to a XML node of a Tiled (TMX) file.
Sint32 CRM64Pro::TE_MapData::loadFromXMLNode (Sint32 idXML)
 Load the mapdata from a node inside a Tiled (TMX) file.
Sint32 CRM64Pro::TE_MapData::cellRender (Sint32 x_cell, Sint32 y_cell, Sint32 x_dst, Sint32 y_dst, Sint32 iAlpha, Sint32 idTileset, Uint32 idTile, Sint32 idRes)
 Render a cell.
Sint32 CRM64Pro::TE_MapData::A2DtoCSV (Uint32 **Array2D, Sint32 w, Sint32 h, char *&szOutput)
 Convert a 2D integers array to a CSV formatted string (SerializeOut).
Sint32 CRM64Pro::TE_MapData::CSVtoA2D (Uint32 **Array2D, Sint32 w, Sint32 h, const string &sInput)
 Convert a CSV formatted string to a 2D integers array (SerializeIn).
Sint32 CRM64Pro::TE_MapData::stringtoA2D (Uint32 **Array2D, Sint32 w, Sint32 h, const char *szInput)
 Convert a string to a 2D integers array (SerializeIn).

Function Documentation

◆ create2DArray()

template<typename T>
T ** CRM64Pro::TE_MapData::create2DArray ( Sint32 height,
Sint32 width )

Template: dynamic 2D array of a given data type.

Parameters
heightSelected height of your 2D array
widthSelected width of your 2D array
Returns
A Pointer to the dynamic 2D array

◆ free2DArray()

template<typename T>
Sint32 CRM64Pro::TE_MapData::free2DArray ( T ** Array)

Template: delete a dynamic 2D array.

Parameters
Arraypointer to 2D array.
Returns
0 on success.

◆ TE_MapData()

CRM64Pro::TE_MapData::TE_MapData ( Sint32 height,
Sint32 width )

MapData constructor.

Creates a 2D array for cells allocation. Each element is a cell.

Parameters
heightSelected height of your map. 0 avoids iTilemap creation.
widthSelected width of your map. 0 avoids iTilemap creation.

◆ getCellWidth()

Sint32 CRM64Pro::TE_MapData::getCellWidth ( )

Get cell width.

Returns
integer with the cell width (in pixels).

◆ setCellWidth()

Sint32 CRM64Pro::TE_MapData::setCellWidth ( Sint32 size)

Set cell width.

Parameters
sizeinteger with cell width (in pixels).
Returns
0 on success, or a negative error code on failure.

◆ getCellHeight()

Sint32 CRM64Pro::TE_MapData::getCellHeight ( )

Get cell height.

Returns
integer with the cell height (in pixels).

◆ setCellHeight()

Sint32 CRM64Pro::TE_MapData::setCellHeight ( Sint32 size)

Set tile height.

Parameters
sizeinteger with cell height (in pixels).
Returns
0 on success, or a negative error code on failure.

◆ getWidth()

Sint32 CRM64Pro::TE_MapData::getWidth ( )

Get map width.

Returns
width of this map(in number of tiles).

◆ getHeight()

Sint32 CRM64Pro::TE_MapData::getHeight ( )

Get map height.

Returns
height of this map(in number of tiles).

◆ create()

Sint32 CRM64Pro::TE_MapData::create ( Sint32 height,
Sint32 width,
Uint32 value = 0 )

Create the 2D array for the tiles allocation.

Each element on this 2D array is a cell.

Parameters
heightSelected height of your map.
widthSelected width of your map.
valueDefault value to be assigned on each cell.
Returns
0 on success, or a negative error code on failure.

◆ free()

Sint32 CRM64Pro::TE_MapData::free ( )

Delete the 2D array.

Returns
0 on success, or a negative error code on failure.

◆ setValue()

Sint32 CRM64Pro::TE_MapData::setValue ( Sint32 y,
Sint32 x,
Uint32 value )

Set arbitrary values on 2D array.

It is mainly used for creating maps in a manual way.

Parameters
ySelected Y position. -1 to affect the whole axis.
xSelected X position. -1 to affect the whole axis.
valueThe value to be set on the given position.
Returns
0 on success, or a negative error code on failure.

◆ clone()

Sint32 CRM64Pro::TE_MapData::clone ( TE_MapData * dest)

Copy the current values of the 2D array iTilemap to the given MapData.

The destination must have identical attributes (width and height). If the destination has not an iTilemap, we will create one identical to the source

Parameters
destPointer to destination TE_MapBase or derivated object.
Returns
0 on success, or a negative error code on failure.

◆ check()

Sint32 CRM64Pro::TE_MapData::check ( )

Map validation.

Validates iTilemap 2D array: prints error info for values <0, checks mapdata width/height, and checks cell width/height.

Returns
0 on success, or a negative error code on failure.

◆ info()

Sint32 CRM64Pro::TE_MapData::info ( Sint8 bTilesetReady,
eLogMessageLevel LML )

Request MapData object information.

Writes information to the default log.

Parameters
bTilesetReady-1 do not display anything, 0 it is not ready and 1 it is ready.
LMLimportance of the message. Check ::eLogMessageLevel enum for further information.
Returns
0 on success, or a negative error code on failure.

◆ saveToXMLNode()

Sint32 CRM64Pro::TE_MapData::saveToXMLNode ( Sint32 idXML)

Save the mapdata to a XML node of a Tiled (TMX) file.

Parameters
idXMLid of an opened XML with the pointer set to a layer subnode.
Returns
0 on success, or a negative error code on failure.

◆ loadFromXMLNode()

Sint32 CRM64Pro::TE_MapData::loadFromXMLNode ( Sint32 idXML)

Load the mapdata from a node inside a Tiled (TMX) file.

Parameters
idXMLid of an opened XML with the pointer set to a data subnode.
Returns
0 on success, or a negative error code on failure.

◆ cellRender()

Sint32 CRM64Pro::TE_MapData::cellRender ( Sint32 x_cell,
Sint32 y_cell,
Sint32 x_dst,
Sint32 y_dst,
Sint32 iAlpha,
Sint32 idTileset,
Uint32 idTile,
Sint32 idRes )

Render a cell.

Parameters
x_cellCell X coordinate to be rendered.
y_cellCell y coordinate to be rendered.
x_dstDestination surface X coordinate to start to render in case you wish to.
y_dstDestination surface Y coordinate to start to render in case you wish to.
iAlphaAlpha modulation for this layer. This value overwrites the own tileset alpha modulation.
idTilesettileset id.
idTilewhich tile inside the tileset must be rendered.
idResa valid screen or image handle used as rendering target.
Returns
0 on success, or a negative error code on failure.
Note
Tiles with different size to the underlying cells is supported: larger tiles will extend at the top and right.

◆ A2DtoCSV()

Sint32 CRM64Pro::TE_MapData::A2DtoCSV ( Uint32 ** Array2D,
Sint32 w,
Sint32 h,
char *& szOutput )
protected

Convert a 2D integers array to a CSV formatted string (SerializeOut).

Parameters
Array2D2D array to be parsed.
wwidth of the 2D array.
hheight of the 2D array.
szOutputPointer to the output string with the integers in CSV format.
Returns
0 on success, or a negative error code on failure.
Note
On successfully calls to this method, a memory allocation for szOutput is done, so once you finish, please remove it using _C64_FREE macro.

◆ CSVtoA2D()

Sint32 CRM64Pro::TE_MapData::CSVtoA2D ( Uint32 ** Array2D,
Sint32 w,
Sint32 h,
const string & sInput )
protected

Convert a CSV formatted string to a 2D integers array (SerializeIn).

Parameters
Array2Ddestination 2D array of the parsed integers.
wwidth of the 2D array.
hheight of the 2D array.
sInputstring with the the integers in CSV format.
Returns
0 on success, or a negative error code on failure.

◆ stringtoA2D()

Sint32 CRM64Pro::TE_MapData::stringtoA2D ( Uint32 ** Array2D,
Sint32 w,
Sint32 h,
const char * szInput )
protected

Convert a string to a 2D integers array (SerializeIn).

Parameters
Array2Ddestination 2D array of the parsed integers.
wwidth of the 2D array.
hheight of the 2D array.
szInputPointer to the input string.
Returns
0 on success, or a negative error code on failure.