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

Description

TileEngine Manager and TileEngine objects for 2D tile-based game development [v25.12.0].

Overview

The TileEngine Core module is a 2D graphics engine that enables you to create tile-based games in a very easy and powerful way. With full support for Tiled map editor (TMX format), you can design your levels using industry-standard tools. Developed from scratch but based on the old MSTE for CRM32Pro, it provides comprehensive support for levels, layers, tilesets and multiple file formats.

Key features

  • Multi-layer architecture: Levels composed of unlimited layers with runtime modification
  • Flexible scrolling: Standard scroll, parallax scroll and auto-scrolling capabilities
  • Multiple tilesets: Use any number of tilesets per layer with variable tile sizes
  • Event system: Layer update and render end events for custom logic
  • Format support: Tiled format, BMP/PNG image import/export
  • Extensible: Custom map data via C++ class inheritance

Level features

The level is the top-level entity created by one or more layers:

View typeOrthogonal view
Layer countAny number of layers, modifiable at runtime
ViewportViewport and render screen modifiable at runtime
Layer groupingIndependent or grouped layers supporting standard or parallax scroll
Auto-scrollBuilt-in auto-scrolling capabilities

Layer features

Layers contain the tile-based data and rendering properties:

DimensionsAny width and height (number of cells)
Cell sizeAny cell size supported
TilesetsAny number of tilesets per layer; larger tiles extend at top and right
Alpha modulation0 (fully transparent) to 255 (fully opaque)
EventsonUpdateEnd and onRenderEnd events for custom logic
Smooth scrollOptional smooth scroll rendering for fluid movement
Custom mapsAdd custom map data via C++ class inheritance
Debug modeRender cell grid for debugging purposes

Tilesets

TypeCRM64Pro::Tile objects
StorageExternal files or CDC archives

Supported formats

TMXFull support for Tiled 0.18+ map files (see TMX compatibility below)
BMP/PNGImport image into layer or export layer to external image

TMX compatibility

Support for Tiled map files with the following specifications:

TMX versionv1.0 to v1.10
OrientationOrthogonal only
Render orderright-down only (if set)
Layer IDStarts with 1
Ignored propertiesinfinite, backgroundcolor
C64TE mapEmbedded inside TMX (current version 3.0)

Manager type

This is a standard manager: objects are not shared and must be unique using its name as the key. You cannot create an object with the same name as another one already created.

Best practices

  • Use parallax scrolling with grouped layers to create depth effects in side-scrolling games
  • Enable smooth scroll rendering for fluid movement in scrolling games
  • Use the onUpdateEnd and onRenderEnd events to add custom game logic per layer
  • Use the debug cell grid rendering during development to verify tile alignment
  • Store tilesets in CDC archives for organized asset management
  • When using Tiled, ensure maps use orthogonal orientation and right-down render order
  • Extend TE_MapData via C++ inheritance for custom map data requirements
  • Access the manager exclusively through Main::ITileEngineMgr()
Note
The TileEngine Manager is a singleton, automatically created once Main is instantiated. You can get a reference to this manager using Main::ITileEngineMgr() method.
The TileEngine Manager is automatically released when Main::Terminate() is called. At this time, any resource still loaded will be released, avoiding resource leaks.

Classes

class  CRM64Pro::TileEngine
 TileEngine Object class. More...
class  CRM64Pro::TileEngineMgr
 TileEngine Manager class. More...

Functions

Sint32 CRM64Pro::TileEngine::info (Sint32 iMode=-1)
 Request TileEngine object information.
Sint32 CRM64Pro::TileEngine::getName (string &sName)
 Get the name.
Uint32 CRM64Pro::TileEngine::getID ()
 Get the ID.
Sint32 CRM64Pro::TileEngine::allocateLayers (Sint32 iN=-1)
 Set or get the number of layers.
Sint32 CRM64Pro::TileEngine::freeLayer (Sint32 layer)
 Free a layer.
Sint32 CRM64Pro::TileEngine::freeLevel ()
 Free all resources of current level (layer maps and tilesets).
Sint32 CRM64Pro::TileEngine::logVerbosity (Sint32)
 Log verbosity control.
Sint32 CRM64Pro::TileEngine::setViewport (SDL_Rect *rect)
 Set the desired viewport.
SDL_Rect * CRM64Pro::TileEngine::getViewport ()
 Get the current viewport.
Sint32 CRM64Pro::TileEngine::setBackgroundColor (Uint32 iRGBA)
 Set background color.
Uint32 CRM64Pro::TileEngine::getBackgroundColor ()
 Get background color.
Sint32 CRM64Pro::TileEngine::getModificationDate (string &sDate)
 Get the level modification date (last save level date).
Sint32 CRM64Pro::TileEngine::getCreationDate (string &sDate)
 Get the level creation date (first save level date).
Sint32 CRM64Pro::TileEngine::loadTileset (Sint32 idRes, Sint32 globalID=-1, Sint32 idTileImg=0)
 Load a tileset.
Sint32 CRM64Pro::TileEngine::loadTileset (const string &sCDCfile, const string &sTileName, Sint32 iID=-1)
 Load a tileset.
Sint32 CRM64Pro::TileEngine::loadTileset (const string &sIMGfile, const string &sTileName, Sint32 iTileWidth, Sint32 iTileHeight, Sint32 iID=-1)
 Load a tileset.
Sint32 CRM64Pro::TileEngine::unloadTileset (Sint32 iTN)
 Unload a given tileset.
Sint32 CRM64Pro::TileEngine::getTileset (Sint32 iTN)
 Get the tileset id.
eTileEngineTilesetType CRM64Pro::TileEngine::getTilesetType (Sint32 iTN)
 Get the tileset type.
Sint32 CRM64Pro::TileEngine::getTilesetSource (Sint32 iTN, string &sName)
 Get tileset source.
Sint32 CRM64Pro::TileEngine::setTilesetSource (Sint32 iTN, const string &sSource)
 Set tileset source.
Sint32 CRM64Pro::TileEngine::setLayerFlags (Sint32 layer, Sint32 iFlags, char iState)
 Set the layer flags.
Sint32 CRM64Pro::TileEngine::getLayerFlags (Sint32 layer)
 Get the layer flags.
Sint32 CRM64Pro::TileEngine::setLayerAlphaMod (Sint32 layer, Sint32 alpha)
 Set layer alpha modulation used for rendering this layer.
Sint32 CRM64Pro::TileEngine::getLayerAlphaMod (Sint32 layer)
 Get layer alpha modulation.
Sint32 CRM64Pro::TileEngine::setLayerParallaxRatio (Sint32 layer, float fPRX, float fPRY)
 Set the layer parallax ratio.
Sint32 CRM64Pro::TileEngine::getLayerParallaxRatio (Sint32 layer, float *fPRX, float *fPRY)
 Get current layer parallax ratio.
Sint32 CRM64Pro::TileEngine::setLayerPosition (Sint32 layer, float xpos=TE_KEEP_VALUE, float ypos=TE_KEEP_VALUE)
 Set the layer absolute position (in pixels).
Sint32 CRM64Pro::TileEngine::getLayerPosition (Sint32 layer, float *xpos, float *ypos)
 Get the current layer position (in pixels).
Sint32 CRM64Pro::TileEngine::setLayerAutoScroll (Sint32 layer, float xspeed=TE_KEEP_VALUE, float yspeed=TE_KEEP_VALUE)
 Set the layer AutoScroll speed (in pixels per second).
Sint32 CRM64Pro::TileEngine::getLayerAutoScroll (Sint32 layer, float *xspeed, float *yspeed)
 Get the layer AutoScroll speed (in pixels per seconds).
Sint32 CRM64Pro::TileEngine::setLayerMapData (Sint32 layer, TE_MapData *map)
 Assign a mapdata to the given layer.
TE_MapDataCRM64Pro::TileEngine::getLayerMapData (Sint32 layer)
 Get current mapdata on the layer.
Sint32 CRM64Pro::TileEngine::setLayerOnUpdateEnd (Sint32 layer, TE_OnLayerEnd myfunc)
 Set an event function (onUpdateEnd) to be called when the engine finishes updating the layer.
TE_OnLayerEnd * CRM64Pro::TileEngine::getLayerOnUpdateEnd (Sint32 layer)
 Get current onUpdateEnd event function if any.
Sint32 CRM64Pro::TileEngine::setLayerOnRenderEnd (Sint32 layer, TE_OnLayerEnd myfunc)
 Set an event function (onRenderEnd) to be called when the engine finishes rendering the layer.
TE_OnLayerEnd * CRM64Pro::TileEngine::getLayerOnRenderEnd (Sint32 layer)
 Get current onRenderEnd event function if any.
Sint32 CRM64Pro::TileEngine::getLayerName (Sint32 layer, string &sName)
 Get the layer name.
Sint32 CRM64Pro::TileEngine::setLayerName (Sint32 layer, const string &sName)
 Set a new layer name.
Sint32 CRM64Pro::TileEngine::setLayerGridColor (Sint32 layer, Uint32 iColor)
 Set the grid color for the base mapdata.
Sint32 CRM64Pro::TileEngine::screen2LayerCell (Sint32 layer, Sint32 sx, Sint32 sy, Sint32 *cx, Sint32 *cy)
 Convert screen coordinates in to layer cell values.
Sint32 CRM64Pro::TileEngine::screen2LayerAbsolute (Sint32 layer, Sint32 sx, Sint32 sy, Sint32 *px, Sint32 *py)
 Convert screen coordinates to layer absolute values.
Sint32 CRM64Pro::TileEngine::moveLayer (Sint32 layer, float x, float y)
 Move the layer by adding or subtracting the given X/Y values.
Sint32 CRM64Pro::TileEngine::update (Sint32 layer=0)
 Update status of TileEngine.
Sint32 CRM64Pro::TileEngine::render (Sint32 layer=0, Sint32 idRes=0)
 Render of visible layers.
Sint32 CRM64Pro::TileEngineMgr::info (Sint32 iMode=0)
 Request TileEngine Manager information.
Sint32 CRM64Pro::TileEngineMgr::create (const string &sName, Uint32 iNumLayers=3)
 Create a new TileEngine.
Sint32 CRM64Pro::TileEngineMgr::close (Sint32 idTE)
 Close and destroy a TileEngine.
Sint32 CRM64Pro::TileEngineMgr::getNum () const
 Get number of loaded objects.
Sint32 CRM64Pro::TileEngineMgr::setName (Sint32 idTE, const string &sName)
 Change the object name.
TileEngineCRM64Pro::TileEngineMgr::get (Sint32 idTE=0)
 Get a pointer to the TileEngine using its handler.

Function Documentation

◆ info() [1/2]

Sint32 CRM64Pro::TileEngine::info ( Sint32 iMode = -1)

Request TileEngine object information.

Writes information to the default log.

Parameters
iMode-1 for displaying information of all layers or greater than 0 for displaying only information of the give layer id.
Returns
0 on success, or a negative error code on failure.

◆ getName()

Sint32 CRM64Pro::TileEngine::getName ( string & sName)

Get the name.

Parameters
sNamea string containing the TileEngine name.
Returns
0 on success, or a negative error code on failure.

◆ getID()

Uint32 CRM64Pro::TileEngine::getID ( )

Get the ID.

Returns
Object ID.

◆ allocateLayers()

Sint32 CRM64Pro::TileEngine::allocateLayers ( Sint32 iN = -1)

Set or get the number of layers.

Parameters
iNnumber of layers to allocate. With -1, returns the current number of allocated layers. If current layers are less than iN, allocates empty new layers. Otherwise removes layers using freeLayer().
Returns
0 on success, or a negative error code on failure.

◆ freeLayer()

Sint32 CRM64Pro::TileEngine::freeLayer ( Sint32 layer)

Free a layer.

Releases the mapdata and resets all layer settings, leaving the slot empty and ready for reuse.

Parameters
layerSelected layer to free (from 1 to number of allocated layers).
Returns
0 on success, or a negative error code on failure.
Note
To remove the layer slot, use allocateLayers().

◆ freeLevel()

Sint32 CRM64Pro::TileEngine::freeLevel ( )

Free all resources of current level (layer maps and tilesets).

Resets the current level. All layers are reset but layer slots are kept. Preserves viewport, level name and number of allocated layers.

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

◆ logVerbosity()

Sint32 CRM64Pro::TileEngine::logVerbosity ( Sint32 iLevel)

Log verbosity control.

Parameters
iLevel0 for disabling the log output, 1 for displaying only LML_CRITICAL, 2 for displaying LML_CRITICAL and LML_NORMAL, 3 for displaying all levels.
Returns
0 on success, or a negative error code on failure.

◆ setViewport()

Sint32 CRM64Pro::TileEngine::setViewport ( SDL_Rect * rect)

Set the desired viewport.

You can change the viewport at any time even while you are rendering your application. The width and height of the viewport can not be greater than values of the smallest layer (excluding the ones with looping flags), otherwise, it will be automatically adjusted.

Parameters
rectPointer to SDL_Rect with the desired viewport. If the rect width or height is 0, it will use the whole target (a valid screen or image handle).
Returns
0 on success, or a negative error code on failure.

◆ getViewport()

SDL_Rect * CRM64Pro::TileEngine::getViewport ( )

Get the current viewport.

Returns
Pointer to a SDL_Rect with the current viewport

◆ setBackgroundColor()

Sint32 CRM64Pro::TileEngine::setBackgroundColor ( Uint32 iRGBA)

Set background color.

Parameters
iRGBAbackground color to set in the format RGBA. When A is 0 (totally transparent), the background color is disabled.
Returns
0 on success, or a negative error code on failure.

◆ getBackgroundColor()

Uint32 CRM64Pro::TileEngine::getBackgroundColor ( )

Get background color.

Returns
the background color in format RGBA. When A is 0 (totally transparent, the background color is disabled)

◆ getModificationDate()

Sint32 CRM64Pro::TileEngine::getModificationDate ( string & sDate)

Get the level modification date (last save level date).

Parameters
sDatea string containing the date.
Returns
0 on success, or a negative error code on failure.

◆ getCreationDate()

Sint32 CRM64Pro::TileEngine::getCreationDate ( string & sDate)

Get the level creation date (first save level date).

Parameters
sDatea string containing the date.
Returns
0 on success, or a negative error code on failure.

◆ loadTileset() [1/3]

Sint32 CRM64Pro::TileEngine::loadTileset ( Sint32 idRes,
Sint32 globalID = -1,
Sint32 idTileImg = 0 )

Load a tileset.

Loads tilesets based on: standard image with tiles (TETT_TILESET) or set of standalone images (TETT_IMAGESET).

Parameters
idResID of a tile or an image. If successfully loaded, TileEngine takes ownership.
globalIDGlobal ID for tileset. Default -1 finds a valid one. 0 not allowed (minimum 1). For TETT_IMAGESET, if globalID exists, tries to add new image.
idTileImgFor TETT_IMAGESET: sets tile id of standalone image.
Returns
greater than 0 on success (the Global ID) or a negative error code on failure.
Note
Default source is TE_TILESET_DEFAULT_SOURCE: tileset saves with level.

◆ loadTileset() [2/3]

Sint32 CRM64Pro::TileEngine::loadTileset ( const string & sCDCfile,
const string & sTileName,
Sint32 iID = -1 )

Load a tileset.

With TERC_AUTO: tileset is automatically removed after usage, szSource is set to the CDC containing the tileset. After loading, tileset is validated.

Parameters
sCDCfilestring with CDC filename containing the tileset.
sTileNamestring with the tilename to load.
iIDGlobal ID for this tileset. Default -1 to find a valid gID. Value 0 not allowed (minimum is 1).
Returns
greater than or equal to 0 on success (the tileset index) or a negative error code on failure.

◆ loadTileset() [3/3]

Sint32 CRM64Pro::TileEngine::loadTileset ( const string & sIMGfile,
const string & sTileName,
Sint32 iTileWidth,
Sint32 iTileHeight,
Sint32 iID = -1 )

Load a tileset.

With TERC_AUTO: tileset is automatically removed after usage, szSource is set to the external image. After loading, tileset is validated.

Parameters
sIMGfilestring with the PNG or BMP filename.
sTileNamestring with the desired tilename.
iTileWidthinteger with the tile width.
iTileHeightinteger with the tile height.
iIDGlobal ID for this tileset. Default -1 to find a valid gID. Value 0 not allowed (minimum is 1).
Returns
greater than or equal to 0 on success (the tileset index) or a negative error code on failure.

◆ unloadTileset()

Sint32 CRM64Pro::TileEngine::unloadTileset ( Sint32 iTN)

Unload a given tileset.

The affected layers (the ones that use any tile of this tileset) will be disabled.

Parameters
iTNGlobal ID or any tile of the tileset to be removed.
Returns
0 on success, or a negative error code on failure.

◆ getTileset()

Sint32 CRM64Pro::TileEngine::getTileset ( Sint32 iTN)

Get the tileset id.

It can be used for modifying any tileset attributes.

Parameters
iTNGlobal ID or any tile of the tileset.
Returns
greater than 0 on success(the Tile id) or a negative error code on failure.

◆ getTilesetType()

eTileEngineTilesetType CRM64Pro::TileEngine::getTilesetType ( Sint32 iTN)

Get the tileset type.

Parameters
iTNGlobal ID or any tile of the tileset.
Returns
check eTileEngineTilesetType for further information.

◆ getTilesetSource()

Sint32 CRM64Pro::TileEngine::getTilesetSource ( Sint32 iTN,
string & sName )

Get tileset source.

The tileset source is used when saving the level.

Parameters
iTNGlobal ID or any tile of the tileset.
sNamea string containing the tile source.
Returns
greater than 0 on success(the Tile id) or a negative error code on failure.

◆ setTilesetSource()

Sint32 CRM64Pro::TileEngine::setTilesetSource ( Sint32 iTN,
const string & sSource )

Set tileset source.

The tileset source is used when saving the level.

Parameters
iTNGlobal ID or any tile of the tileset.
sSourceNew source: TE_TILESET_DEFAULT_SOURCE, a full path and filename of a CDC, PNG or BMP.
Returns
0 on success, or a negative error code on failure.

◆ setLayerFlags()

Sint32 CRM64Pro::TileEngine::setLayerFlags ( Sint32 layer,
Sint32 iFlags,
char iState )

Set the layer flags.

Parameters
layerNumber of layer(from 1 to number of allocated layers)
iFlagsSee TE_LAYERFLAG_xxx defines for further information. They can be OR'ed
iState<=0 for disabling the given bFlags or >1 for enabling it. With TE_LAYERFLAG_DISABLE it does not have sense.
Returns
0 on success, or a negative error code on failure.
Note
TE_LAYERFLAG_SHOWGRID only works with layers with mapdata, layers with an image are not working.

◆ getLayerFlags()

Sint32 CRM64Pro::TileEngine::getLayerFlags ( Sint32 layer)

Get the layer flags.

Parameters
layerNumber of layer(from 1 to number of allocated layers)
Returns
the status flags (see TE_LAYERFLAG_xxx defines for further information) or a negative error code on failure.

◆ setLayerAlphaMod()

Sint32 CRM64Pro::TileEngine::setLayerAlphaMod ( Sint32 layer,
Sint32 alpha )

Set layer alpha modulation used for rendering this layer.

Parameters
layerSelected layer to set the alpha value (from 1 to number of allocated layers).
alphaIt ranges from 255 (opaque) to 0 (fully transparent).
Returns
0 on success, or a negative error code on failure.

◆ getLayerAlphaMod()

Sint32 CRM64Pro::TileEngine::getLayerAlphaMod ( Sint32 layer)

Get layer alpha modulation.

Parameters
layerSelected layer to get the alpha value (from 1 to number of allocated layers)
Returns
It ranges from 255 (opaque) to 0 (fully transparent) or a negative error code on failure.

◆ setLayerParallaxRatio()

Sint32 CRM64Pro::TileEngine::setLayerParallaxRatio ( Sint32 layer,
float fPRX,
float fPRY )

Set the layer parallax ratio.

Changes the real speed of any layer without affecting the rest.

Parameters
layerSelected layer to set the parallax ratio (from 1 to number of allocated layers).
fPRXParallax ratio on X axis. 0 makes layer independent on X axis, any other value links it.
fPRYParallax ratio on Y axis. 0 makes layer independent on Y axis, any other value links it. If any linked layer moves, it affects others using this ratio as base.
Returns
0 on success, or a negative error code on failure.

◆ getLayerParallaxRatio()

Sint32 CRM64Pro::TileEngine::getLayerParallaxRatio ( Sint32 layer,
float * fPRX,
float * fPRY )

Get current layer parallax ratio.

Parameters
layerSelected layer to get the parallax ratio (from 1 to number of allocated layers).
fPRXa float pointer filled in with parallax ratio on X axis. If nullptr is passed, the method ignores the retrieving of this value.
fPRYa float pointer filled in with parallax ratio on Y axis. If nullptr is passed, the method ignores the retrieving of this value.
Returns
0 on success, or a negative error code on failure.

◆ setLayerPosition()

Sint32 CRM64Pro::TileEngine::setLayerPosition ( Sint32 layer,
float xpos = TE_KEEP_VALUE,
float ypos = TE_KEEP_VALUE )

Set the layer absolute position (in pixels).

Changes position for linked layers according to parallax ratios. Layers with parallax ratio 0.0 are independent. Requires valid base mapdata or image set. Special flags: TE_KEEP_VALUE (keep axis value), TE_LAYERPOSITION_BEGINNING/MIDDLE/END (move layer, skips smoothing), TE_LAYERPOSITION_CENTER (center based on viewport).

Parameters
layerSelected layer to set position (from 1 to number of allocated layers).
xposFlag or value for X axis position.
yposFlag or value for Y axis position.
Returns
0 on success (no change), 1 on success (changed) or a negative error code on failure.

◆ getLayerPosition()

Sint32 CRM64Pro::TileEngine::getLayerPosition ( Sint32 layer,
float * xpos,
float * ypos )

Get the current layer position (in pixels).

Parameters
layerSelected layer to get its current position (from 1 to number of allocated layers).
xposPointer to float var to store the position on X axis. nullptr if you dont want to retrieve it.
yposPointer to float var to store the position on Y axis. nullptr if you dont want to retrieve it.
Returns
0 on success, or a negative error code on failure.

◆ setLayerAutoScroll()

Sint32 CRM64Pro::TileEngine::setLayerAutoScroll ( Sint32 layer,
float xspeed = TE_KEEP_VALUE,
float yspeed = TE_KEEP_VALUE )

Set the layer AutoScroll speed (in pixels per second).

Changes AutoScroll speed for linked layers according to parallax ratios.

Parameters
layerSelected layer to set autoscroll speed (from 1 to number of allocated layers).
xspeedTE_KEEP_VALUE keeps current X speed. Any other value sets it.
yspeedTE_KEEP_VALUE keeps current Y speed. Any other value sets it.
Returns
0 on success, or a negative error code on failure.

Changing speed of others layers. With ratio=0, independent layer.

◆ getLayerAutoScroll()

Sint32 CRM64Pro::TileEngine::getLayerAutoScroll ( Sint32 layer,
float * xspeed,
float * yspeed )

Get the layer AutoScroll speed (in pixels per seconds).

Parameters
layerSelected layer to get its current AutoScroll speed (from 1 to number of allocated layers).
xspeedPointer to float var to store the speed on X axis. nullptr if you dont want to retrieve it.
yspeedPointer to float var to store the speed on Y axis. nullptr if you dont want to retrieve it.
Returns
0 on success, or a negative error code on failure.

◆ setLayerMapData()

Sint32 CRM64Pro::TileEngine::setLayerMapData ( Sint32 layer,
TE_MapData * map )

Assign a mapdata to the given layer.

If the mapdata is already set, it will remove it following resource control policies (see ::eTileEngineResCtrl for further information)

Parameters
layerSelected layer to try to set a new mapdata (from 1 to number of allocated layers)
mapPointer to a valid mapdata: TE_MapData or a derivated one. nullptr to try to remove the existing mapdata.
Returns
0 on success, or a negative error code on failure.
Note
This method does not work with image layers.

◆ getLayerMapData()

TE_MapData * CRM64Pro::TileEngine::getLayerMapData ( Sint32 layer)

Get current mapdata on the layer.

Parameters
layerSelected layer to try to get its mapdata (from 1 to number of allocated layers).
Returns
a pointer to the TE_MapData/derivated one or nullptr if there is not any assigned.

◆ setLayerOnUpdateEnd()

Sint32 CRM64Pro::TileEngine::setLayerOnUpdateEnd ( Sint32 layer,
TE_OnLayerEnd myfunc )

Set an event function (onUpdateEnd) to be called when the engine finishes updating the layer.

Use nullptr to remove a previous onUpdateEnd event function.

Parameters
layerNumber of layer to set the event function (from 1 to number of allocated layers).
myfuncpointer to your custom event function.
Returns
0 on success, or a negative error code on failure.

◆ getLayerOnUpdateEnd()

TileEngine::TE_OnLayerEnd * CRM64Pro::TileEngine::getLayerOnUpdateEnd ( Sint32 layer)

Get current onUpdateEnd event function if any.

Parameters
layerSelected layer to get current onUpdateEnd event function (from 1 to number of allocated layers).
Returns
a pointer to current event function or nullptr if there is not any assigned.

◆ setLayerOnRenderEnd()

Sint32 CRM64Pro::TileEngine::setLayerOnRenderEnd ( Sint32 layer,
TE_OnLayerEnd myfunc )

Set an event function (onRenderEnd) to be called when the engine finishes rendering the layer.

Use nullptr to remove a previous onRenderEnd event function.

Parameters
layerNumber of layer to set the event function (from 1 to number of allocated layers).
myfuncpointer to your custom event function.
Returns
0 on success, or a negative error code on failure.

◆ getLayerOnRenderEnd()

TileEngine::TE_OnLayerEnd * CRM64Pro::TileEngine::getLayerOnRenderEnd ( Sint32 layer)

Get current onRenderEnd event function if any.

Parameters
layerSelected layer to get current onRenderEnd event function (from 1 to number of allocated layers).
Returns
a pointer to current event function or nullptr if there is not any assigned.

◆ getLayerName()

Sint32 CRM64Pro::TileEngine::getLayerName ( Sint32 layer,
string & sName )

Get the layer name.

Parameters
layerSelected layer to get its name (from 1 to number of allocated layers).
sNamea string containing the layer name.
Returns
0 on success, or a negative error code on failure.

◆ setLayerName()

Sint32 CRM64Pro::TileEngine::setLayerName ( Sint32 layer,
const string & sName )

Set a new layer name.

Parameters
layerSelected layer to set its name (from 1 to number of allocated layers).
sNameThe name to give to the layer e.g. 'layer0'.
Returns
0 on success, or a negative error code on failure.

◆ setLayerGridColor()

Sint32 CRM64Pro::TileEngine::setLayerGridColor ( Sint32 layer,
Uint32 iColor )

Set the grid color for the base mapdata.

It is used for debugging purposes

Parameters
layerSelected layer to set the grid color (from 1 to number of allocated layers).
iColorpacked unsigned int with the color value (RGBA).
Returns
0 on success, or a negative error code on failure.

◆ screen2LayerCell()

Sint32 CRM64Pro::TileEngine::screen2LayerCell ( Sint32 layer,
Sint32 sx,
Sint32 sy,
Sint32 * cx,
Sint32 * cy )

Convert screen coordinates in to layer cell values.

Parameters
layerSelected layer (from 1 to number of allocated layers).
sxScreen X coordinate (mouse position, etc.).
syScreen Y coordinate (mouse position, etc.).
cxPoint to integer where the Cell X position will be returned if this method call succeed.
cyPoint to integer where the Cell Y position will be returned if this method call succeed.
Returns
0 on success, or a negative error code on failure.
Note
This method does not work with image layers.

◆ screen2LayerAbsolute()

Sint32 CRM64Pro::TileEngine::screen2LayerAbsolute ( Sint32 layer,
Sint32 sx,
Sint32 sy,
Sint32 * px,
Sint32 * py )

Convert screen coordinates to layer absolute values.

Parameters
layerSelected layer (from 1 to number of allocated layers).
sxScreen X coordinate (mouse position, etc.).
syScreen Y coordinate (mouse position, etc.).
pxPoint to integer where the absolute X position will be returned if this method call succeed.
pyPoint to integer where the absolute Y position will be returned if this method call succeed.
Returns
0 on success, or a negative error code on failure.

◆ moveLayer()

Sint32 CRM64Pro::TileEngine::moveLayer ( Sint32 layer,
float x,
float y )

Move the layer by adding or subtracting the given X/Y values.

Changes position for linked layers according to parallax ratios. Layers with parallax ratio 0.0 are independent.

Parameters
layerSelected layer to move (from 1 to number of allocated layers).
xFloat X value, positive or negative. 0 does nothing.
yFloat Y value, positive or negative. 0 does nothing.
Returns
0 on success (no change), 1 on success (changed) or a negative error code on failure.

◆ update()

Sint32 CRM64Pro::TileEngine::update ( Sint32 layer = 0)

Update status of TileEngine.

Only layers with TE_LAYERFLAG_UPDATE flag are processed. Calculates autoscroll and pre-calculations for rendering. Call as part of logic code. Optionally update individual layers. Calls onUpdateEnd event function at end of each layer update if it exists.

Parameters
layerDefault 0 updates all layers from 1 (background) to foreground. Any other value updates only that layer.
Returns
0 on success, or a negative error code on failure.

◆ render()

Sint32 CRM64Pro::TileEngine::render ( Sint32 layer = 0,
Sint32 idRes = 0 )

Render of visible layers.

Only layers with TE_LAYERFLAG_RENDER flag are processed. Uses positions from update() to render cells. Call as part of graphic update code. Select rendering order by calling with specific layers. Calls onRenderEnd at end of each layer. With TE_LAYERFLAG_SMOOTHSCROLL, interpolates values for smooth scrolling.

Parameters
layerDefault 0 processes all layers. Values 1 (background) to foreground process only that layer.
idResa valid screen. Default tries the default screen. Does not support rendering to an image.
Returns
0 on success, or a negative error code on failure.

◆ info() [2/2]

Sint32 CRM64Pro::TileEngineMgr::info ( Sint32 iMode = 0)

Request TileEngine Manager information.

Writes information to the default log.

Parameters
iMode-1 for Manager info only. 0 (default) for Manager and all Objects. A positive TE id for Manager and that specific TileEngine.
Returns
0 on success, or a negative error code on failure.

◆ create()

Sint32 CRM64Pro::TileEngineMgr::create ( const string & sName,
Uint32 iNumLayers = 3 )

Create a new TileEngine.

Default viewport is 320x200 starting at (0,0).

Parameters
sNameThe level name (e.g. 'myLevel'), also used for TileEngine object name. Must be unique and max 64 characters (truncated if longer).
iNumLayerslayers to allocate. Default 3. Use allocateLayers() to dynamically change this.
Returns
greater than 0 on success (the TileEngine id) or a negative error code on failure.

◆ close()

Sint32 CRM64Pro::TileEngineMgr::close ( Sint32 idTE)

Close and destroy a TileEngine.

Parameters
idTE0 for closing all TileEngine objects or a specific TileEngine id.
Returns
0 on success, or a negative error code on failure.
Note
Unclosed TileEngines are automatically closed when GDK terminates. Tilesets/mapdata with TERC_USER resource control must be freed manually after calling this method.

◆ getNum()

Sint32 CRM64Pro::TileEngineMgr::getNum ( ) const

Get number of loaded objects.

Returns
the number of TileEngine objects.

◆ setName()

Sint32 CRM64Pro::TileEngineMgr::setName ( Sint32 idTE,
const string & sName )

Change the object name.

Parameters
idTETileEngine id.
sNameThe name (e.g. 'myTE'). Must be unique and max 64 characters (truncated if longer).
Returns
0 on success, or a negative error code on failure.

◆ get()

TileEngine * CRM64Pro::TileEngineMgr::get ( Sint32 idTE = 0)

Get a pointer to the TileEngine using its handler.

Parameters
idTETileEngine id. By default it returns the first TileEngine.
Returns
nullptr the TileEngine was not found.
A pointer to the TileEngine object.