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

TileEngine Object class. More...

Detailed Description

TileEngine Object class.

Public Member Functions

Sint32 info (Sint32 iMode=-1)
 Request TileEngine object information.
Sint32 getName (string &sName)
 Get the name.
Uint32 getID ()
 Get the ID.
Sint32 allocateLayers (Sint32 iN=-1)
 Set or get the number of layers.
Sint32 freeLayer (Sint32 layer)
 Free a layer.
Sint32 freeLevel ()
 Free all resources of current level (layer maps and tilesets).
Sint32 logVerbosity (Sint32)
 Log verbosity control.
Sint32 setViewport (SDL_Rect *rect)
 Set the desired viewport.
SDL_Rect * getViewport ()
 Get the current viewport.
Sint32 setBackgroundColor (Uint32 iRGBA)
 Set background color.
Uint32 getBackgroundColor ()
 Get background color.
Sint32 getModificationDate (string &sDate)
 Get the level modification date (last save level date).
Sint32 getCreationDate (string &sDate)
 Get the level creation date (first save level date).
Sint32 loadTileset (Sint32 idRes, Sint32 globalID=-1, Sint32 idTileImg=0)
 Load a tileset.
Sint32 loadTileset (const string &sCDCfile, const string &sTileName, Sint32 iID=-1)
 Load a tileset.
Sint32 loadTileset (const string &sIMGfile, const string &sTileName, Sint32 iTileWidth, Sint32 iTileHeight, Sint32 iID=-1)
 Load a tileset.
Sint32 unloadTileset (Sint32 iTN)
 Unload a given tileset.
Sint32 getTileset (Sint32 iTN)
 Get the tileset id.
eTileEngineTilesetType getTilesetType (Sint32 iTN)
 Get the tileset type.
Sint32 getTilesetSource (Sint32 iTN, string &sName)
 Get tileset source.
Sint32 setTilesetSource (Sint32 iTN, const string &sSource)
 Set tileset source.
Sint32 setLayerFlags (Sint32 layer, Sint32 iFlags, char iState)
 Set the layer flags.
Sint32 getLayerFlags (Sint32 layer)
 Get the layer flags.
Sint32 setLayerAlphaMod (Sint32 layer, Sint32 alpha)
 Set layer alpha modulation used for rendering this layer.
Sint32 getLayerAlphaMod (Sint32 layer)
 Get layer alpha modulation.
Sint32 setLayerParallaxRatio (Sint32 layer, float fPRX, float fPRY)
 Set the layer parallax ratio.
Sint32 getLayerParallaxRatio (Sint32 layer, float *fPRX, float *fPRY)
 Get current layer parallax ratio.
Sint32 setLayerPosition (Sint32 layer, float xpos=TE_KEEP_VALUE, float ypos=TE_KEEP_VALUE)
 Set the layer absolute position (in pixels).
Sint32 getLayerPosition (Sint32 layer, float *xpos, float *ypos)
 Get the current layer position (in pixels).
Sint32 setLayerAutoScroll (Sint32 layer, float xspeed=TE_KEEP_VALUE, float yspeed=TE_KEEP_VALUE)
 Set the layer AutoScroll speed (in pixels per second).
Sint32 getLayerAutoScroll (Sint32 layer, float *xspeed, float *yspeed)
 Get the layer AutoScroll speed (in pixels per seconds).
Sint32 setLayerMapData (Sint32 layer, TE_MapData *map)
 Assign a mapdata to the given layer.
TE_MapDatagetLayerMapData (Sint32 layer)
 Get current mapdata on the layer.
Sint32 setLayerOnUpdateEnd (Sint32 layer, TE_OnLayerEnd myfunc)
 Set an event function (onUpdateEnd) to be called when the engine finishes updating the layer.
TE_OnLayerEnd * getLayerOnUpdateEnd (Sint32 layer)
 Get current onUpdateEnd event function if any.
Sint32 setLayerOnRenderEnd (Sint32 layer, TE_OnLayerEnd myfunc)
 Set an event function (onRenderEnd) to be called when the engine finishes rendering the layer.
TE_OnLayerEnd * getLayerOnRenderEnd (Sint32 layer)
 Get current onRenderEnd event function if any.
Sint32 getLayerName (Sint32 layer, string &sName)
 Get the layer name.
Sint32 setLayerName (Sint32 layer, const string &sName)
 Set a new layer name.
Sint32 setLayerGridColor (Sint32 layer, Uint32 iColor)
 Set the grid color for the base mapdata.
Sint32 screen2LayerCell (Sint32 layer, Sint32 sx, Sint32 sy, Sint32 *cx, Sint32 *cy)
 Convert screen coordinates in to layer cell values.
Sint32 screen2LayerAbsolute (Sint32 layer, Sint32 sx, Sint32 sy, Sint32 *px, Sint32 *py)
 Convert screen coordinates to layer absolute values.
Sint32 moveLayer (Sint32 layer, float x, float y)
 Move the layer by adding or subtracting the given X/Y values.
Sint32 update (Sint32 layer=0)
 Update status of TileEngine.
Sint32 render (Sint32 layer=0, Sint32 idRes=0)
 Render of visible layers.
Sint32 importLayerFromFile (Sint32 layer, const string &sFile, const string &sLayerName, Sint32 tileSizeX, Sint32 tileSizeY, float maxDevPercentage=100.0, Sint32 iCK=-1)
 Import an image file (BMP or PNG) into a layer.
Sint32 importLayerFromImage (Sint32 layer, Sint32 idImg, const string &sLayerName, Sint32 tileSizeX, Sint32 tileSizeY, float maxDevPercentage=100.0, Sint32 iCK=-1)
 Import an image into a layer.
Sint32 exportLayerToFile (Sint32 layer, const string &sFile)
 Export a layer to an external PNG image.
Sint32 exportLayerToImage (Sint32 layer, Sint32 idImg)
 Export a layer to an image.
Sint32 exportTMX (const string &sTMXFile, const string &sLevelName="", const string &sCDCFile="")
 Export level to a Tiled map (TMX).

Member Function Documentation

◆ importLayerFromFile()

Sint32 CRM64Pro::TileEngine::importLayerFromFile ( Sint32 layer,
const string & sFile,
const string & sLayerName,
Sint32 tileSizeX,
Sint32 tileSizeY,
float maxDevPercentage = 100.0,
Sint32 iCK = -1 )

Import an image file (BMP or PNG) into a layer.

Creates a new base mapdata and tileset. Selected layer must be empty (no mapdata). Level name is used for layer and tileset names.

Parameters
layerSelected layer ID (from 1 to number of allocated layers).
sFilestring containing [directory]+filename+[BMP or PNG extension]. Directory separators '\' and '/' are supported.
sLayerNamelayer name. If empty, file name is used.
tileSizeXTile width to divide image. 0 creates an imagelayer.
tileSizeYTile height to divide image. 0 creates an imagelayer.
maxDevPercentagePercentage of differing pixels before tile is unique. Default 100% gets only identical tiles.
iCKFor images without alpha, this RGB color is transparent. Default -1 (disabled).
Returns
0 on success, or a negative error code on failure.
Note
Tileset has proportional size to tile sizes. Sizes > 4096 trigger a warning (some backends don't support them).

◆ importLayerFromImage()

Sint32 CRM64Pro::TileEngine::importLayerFromImage ( Sint32 layer,
Sint32 idImg,
const string & sLayerName,
Sint32 tileSizeX,
Sint32 tileSizeY,
float maxDevPercentage = 100.0,
Sint32 iCK = -1 )

Import an image into a layer.

Creates a new base mapdata and tileset. Selected layer must be empty (no mapdata). Level name is used for layer and tileset names.

Parameters
layerSelected layer ID (from 1 to number of allocated layers).
idImgImage ID to import.
sLayerNamelayer name. If empty, image name is used.
tileSizeXTile width to divide image. 0 creates an imagelayer.
tileSizeYTile height to divide image. 0 creates an imagelayer.
maxDevPercentagePercentage of differing pixels before tile is unique. Default 100% gets only identical tiles.
iCKFor images without alpha, this RGB color is transparent. Default -1 (disabled).
Returns
0 on success, or a negative error code on failure.
Note
Tileset has proportional size to tile sizes. Sizes > 4096 trigger a warning (some backends don't support them).

◆ exportLayerToFile()

Sint32 CRM64Pro::TileEngine::exportLayerToFile ( Sint32 layer,
const string & sFile )

Export a layer to an external PNG image.

Parameters
layerLayer to export, from 1 to number of allocated layers or 0 to export all layers. The layer must has TE_LAYERFLAG_RENDER flag.
sFilestring containing the [directory]+filename+[extension].
Returns
0 on success, or a negative error code on failure.

◆ exportLayerToImage()

Sint32 CRM64Pro::TileEngine::exportLayerToImage ( Sint32 layer,
Sint32 idImg )

Export a layer to an image.

Parameters
layerLayer to export, from 1 to number of allocated layers or 0 to export all layers. The layer must has TE_LAYERFLAG_RENDER flag.
idImgImage ID. The image should not have assigned any surface.
Returns
0 on success, or a negative error code on failure.

◆ exportTMX()

Sint32 CRM64Pro::TileEngine::exportTMX ( const string & sTMXFile,
const string & sLevelName = "",
const string & sCDCFile = "" )

Export level to a Tiled map (TMX).

Supports TMX v1.10 files, orthogonal view. Creates an embedded C64TE map format.

Parameters
sTMXFilestring containing [directory]+filename+[extension] of TMX file. Directory separators '\' and '/' are supported.
sLevelNamelevel name for TMX, overwriting current name. Default uses existing level name.
sCDCFilestring containing [directory]+filename+[extension] of CDC file for resources. If empty, resources saved as external files. Directory separators '\' and '/' are supported.
Returns
0 on success, or a negative error code on failure.