![]() |
CRM64Pro GDK v0.15.0
A free cross-platform game development kit built on top of SDL 3.0
|
Tile Manager and Tile objects for handling tiles and tilesets [v26.02.0].
The Tile module provides management for tiles and tilesets. Tiles are smaller images of uniform, rectangular size that can be combined into larger "image maps", allowing the creation of huge game maps while saving significant memory. A collection of tiles is called a tileset, where tile dimensions are defined by X and Y offsets.
| Tileset management | Create, load, save and manage complete tilesets |
|---|---|
| Tile access | Access individual tiles by index within a tileset |
| Image integration | Get Image ID to access the underlying Image object (export, alpha modulation, etc.) |
| Format | CDC v1.x specification |
|---|---|
| load() | Load tileset from CDC archive |
| save() | Save tileset to CDC archive |
This is an advanced "cloning" manager: when loading a tile from a CDC file that is already loaded or created (using the name as the key), it will create a new child tile. Child tiles share base data with the parent while allowing independent modifications.
Resource names are restricted to prevent collisions with system assets. The characters '#' and '@' are reserved for internal engine use. Any attempt to create or rename a resource starting with these characters will be rejected (returning a negative error code).
Classes | |
| class | CRM64Pro::Tile |
| Tile Object class. More... | |
| class | CRM64Pro::TileMgr |
| Tile Manager class. More... | |
Functions | |
| bool | CRM64Pro::Tile::info (Sint32 iMode=0) override |
| Request Tile object information. | |
| const string & | CRM64Pro::Tile::getName () const override |
| Get the name. | |
| Uint32 | CRM64Pro::Tile::getID () const override |
| Get the ID. | |
| Sint32 | CRM64Pro::Tile::assignImage (Sint32 idImage, Sint32 iOwnership=0) |
| Assign an Image to this tile. | |
| Sint32 | CRM64Pro::Tile::getImage () const |
| Get the assigned Image of this tile. | |
| bool | CRM64Pro::Tile::setOffset (Sint32 iTSMode, Sint32 iX, Sint32 iY) |
| Set tileset mode and offset. | |
| bool | CRM64Pro::Tile::getOffset (Sint32 *iX, Sint32 *iY) const |
| Get the tile offsets (tileset attributes). | |
| bool | CRM64Pro::Tile::setPosition (float fX, float fY) |
| Set the tile position. | |
| float | CRM64Pro::Tile::getX () const |
| Get the tile X position. | |
| float | CRM64Pro::Tile::getY () const |
| Get the tile Y position. | |
| Sint32 | CRM64Pro::Tile::getTileCount (Sint32 *iX=nullptr, Sint32 *iY=nullptr) const |
| Get the number of tiles. | |
| Sint32 | CRM64Pro::Tile::render (Sint32 iTS=1, Sint32 idRes=0) |
| Render the tile. | |
| Sint32 | CRM64Pro::Tile::renderEx (Sint32 iTS=1, float fScaleX=1.0f, float fScaleY=1.0f, const double dAngle=0.0, const SDL_FPoint *poCenter=nullptr, const SDL_FlipMode rf=SDL_FLIP_NONE, Sint32 idRes=0) |
| Render the tile with extended attributes. | |
| Sint32 | CRM64Pro::Tile::save (const string &sCDCFile, const string &sResourceName="") |
| Save the tile to a CDC file. | |
| Sint32 | CRM64Pro::Tile::save (const Sint32 idCDC, const string &sResourceName="") |
| Save the tile to a CDC file. | |
| bool | CRM64Pro::TileMgr::info (Sint32 iMode=0) override |
| Request Tile Manager information. | |
| Sint32 | CRM64Pro::TileMgr::create (const string &sName, Uint32 iVersion=10) override |
| Create a new tile. | |
| bool | CRM64Pro::TileMgr::close (Sint32 idTile) override |
| Close and destroy a tile. | |
| Sint32 | CRM64Pro::TileMgr::getCount () const override |
| Get number of loaded objects. | |
| Sint32 | CRM64Pro::TileMgr::setName (Sint32 idTile, const string &sName) override |
| Change the object name. | |
| Tile * | CRM64Pro::TileMgr::get (Sint32 idTile) |
| Get a pointer to the tile using its handler. | |
| Sint32 | CRM64Pro::TileMgr::child (Sint32 idTile) |
| Create a child tile dependent on the provided one (the parent). | |
| Sint32 | CRM64Pro::TileMgr::load (const string &sCDCFile, const string &sName) |
| Load a tile stored in a CDC file. | |
| Sint32 | CRM64Pro::TileMgr::load (const Sint32 idCDC, const string &sName) |
| Load a tile stored in a CDC file. | |
| Sint32 | CRM64Pro::TileMgr::loadFromBuffer (const void *pBuffer, Sint32 iSize, const string &sName, Uint32 iW=0, Uint32 iH=0) |
| Load a tileset from an image memory buffer. | |
| Sint32 | CRM64Pro::TileMgr::remove (const Sint32 idCDC, const string &sName) |
| Remove a tile stored in a CDC file. | |
| bool | CRM64Pro::TileMgr::exist (const Sint32 idCDC, const string &sName) |
| Check if a tile is stored in a CDC file. | |
| bool | CRM64Pro::TileMgr::exist (const string &sCDCFile, const string &sName) |
| Check if a tile is stored in a CDC file. | |
|
override |
Request Tile object information.
Writes information to the default log.
| iMode | unused for the time being. |
|
override |
Get the name.
|
override |
Get the ID.
| Sint32 CRM64Pro::Tile::assignImage | ( | Sint32 | idImage, |
| Sint32 | iOwnership = 0 ) |
Assign an Image to this tile.
Used for loading an Image when the tile is created with TileMgr::create().
| idImage | Image id. |
| iOwnership | 0 (default) creates a copy; any other value takes ownership (image cannot be owned by another item). |
| Sint32 CRM64Pro::Tile::getImage | ( | ) | const |
Get the assigned Image of this tile.
| bool CRM64Pro::Tile::setOffset | ( | Sint32 | iTSMode, |
| Sint32 | iX, | ||
| Sint32 | iY ) |
Set tileset mode and offset.
In tileset mode, the image is divided by iX on X axis and by iY on Y axis. Non-exact divisions are allowed; remainder parts are unused.
| iTSMode | 0 for disable tileset mode or 1 for enable it. |
| iX | tileset offset X. |
| iY | tileset offset Y. |
| bool CRM64Pro::Tile::getOffset | ( | Sint32 * | iX, |
| Sint32 * | iY ) const |
Get the tile offsets (tileset attributes).
| iX | an integer pointer filled in with tileset offset X. If nullptr is passed, the method ignores the retrieving of this value. |
| iY | an integer pointer filled in with tileset offset Y. If nullptr is passed, the method ignores the retrieving of this value. |
| bool CRM64Pro::Tile::setPosition | ( | float | fX, |
| float | fY ) |
Set the tile position.
| fX | tile X position. |
| fY | tile Y position. |
| float CRM64Pro::Tile::getX | ( | ) | const |
Get the tile X position.
| float CRM64Pro::Tile::getY | ( | ) | const |
Get the tile Y position.
| Sint32 CRM64Pro::Tile::getTileCount | ( | Sint32 * | iX = nullptr, |
| Sint32 * | iY = nullptr ) const |
Get the number of tiles.
| iX | an integer pointer filled in with the tiles on the X axis. If nullptr is passed (default value), the method ignores the retrieving of this value. |
| iY | an integer pointer filled in with the tiles on the Y axis. If nullptr is passed (default value), the method ignores the retrieving of this value. |
| Sint32 CRM64Pro::Tile::render | ( | Sint32 | iTS = 1, |
| Sint32 | idRes = 0 ) |
Render the tile.
| iTS | tile id from the current tileset. From 1 to number of tiles. |
| idRes | a valid screen or image handle. Default uses the default screen. |
| Sint32 CRM64Pro::Tile::renderEx | ( | Sint32 | iTS = 1, |
| float | fScaleX = 1.0f, | ||
| float | fScaleY = 1.0f, | ||
| const double | dAngle = 0.0, | ||
| const SDL_FPoint * | poCenter = nullptr, | ||
| const SDL_FlipMode | rf = SDL_FLIP_NONE, | ||
| Sint32 | idRes = 0 ) |
Render the tile with extended attributes.
| iTS | tile id from the current tileset. From 1 to number of tiles. |
| fScaleX | X scaling factor. |
| fScaleY | Y scaling factor. |
| dAngle | angle in degrees for rotation. |
| poCenter | SDL_FPoint pointer indicating rotation center. Default nullptr rotates around rDst.w/2 and rDst.h/2. |
| rf | "SDL_FlipMode" value for flipping actions. |
| idRes | a valid screen or image handle. Default uses the default screen. |
| Sint32 CRM64Pro::Tile::save | ( | const string & | sCDCFile, |
| const string & | sResourceName = "" ) |
Save the tile to a CDC file.
The associated image will also be saved to the same CDC file.
| sCDCFile | string containing [directory]+filename+[extension]. Directory separators '\' and '/' are supported. |
| sResourceName | Optional resource name to use in the CDC. If empty (default), uses the Tile object's internal name. |
| Sint32 CRM64Pro::Tile::save | ( | const Sint32 | idCDC, |
| const string & | sResourceName = "" ) |
Save the tile to a CDC file.
The associated image will also be saved to the same CDC file.
| idCDC | CDC id. |
| sResourceName | Optional resource name to use in the CDC. If empty (default), uses the Tile object's internal name. |
|
override |
Request Tile Manager information.
Writes information to the default log.
| iMode | -1 to display only manager information. 0 (default) to display manager and all objects. Specific object ID to display manager and only that object. |
|
override |
Create a new tile.
Creates an empty tile (no image). Use Tile::assignImage() to assign an image.
| sName | The tile name (e.g. 'myTile'). Must be unique, max 64 characters. |
| iVersion | Tile version. 10 means v1.0 (only version supported). Default v1.0. |
|
override |
Close and destroy a tile.
| idTile | 0 for closing all tiles or the Tile id. Stand-alone and child tiles can be closed but parent ones, can not as they have at least one dependency (a child). |
|
override |
Get number of loaded objects.
|
override |
Change the object name.
| idTile | Tile id. |
| sName | The tile name (e.g. 'myTile'). Must be unique, max 64 characters. |
| Tile * CRM64Pro::TileMgr::get | ( | Sint32 | idTile | ) |
Get a pointer to the tile using its handler.
| idTile | Tile id. |
| Sint32 CRM64Pro::TileMgr::child | ( | Sint32 | idTile | ) |
Create a child tile dependent on the provided one (the parent).
A child tile uses parent's attributes and creates a child image for different attributes.
| idTile | parent Tile id. If the provided tile is a child, the request is redirected to its parent. |
| Sint32 CRM64Pro::TileMgr::load | ( | const string & | sCDCFile, |
| const string & | sName ) |
Load a tile stored in a CDC file.
| sCDCFile | string containing [directory]+filename. Directory separators '\' and '/' are supported. |
| sName | string with the tile name (max 64 characters). If already exists, creates a child instead. |
| Sint32 CRM64Pro::TileMgr::load | ( | const Sint32 | idCDC, |
| const string & | sName ) |
Load a tile stored in a CDC file.
| idCDC | CDC id. |
| sName | string with the tile name (max 64 characters). If already exists, creates a child instead. |
| Sint32 CRM64Pro::TileMgr::loadFromBuffer | ( | const void * | pBuffer, |
| Sint32 | iSize, | ||
| const string & | sName, | ||
| Uint32 | iW = 0, | ||
| Uint32 | iH = 0 ) |
Load a tileset from an image memory buffer.
| pBuffer | Pointer to the memory buffer containing the image (BMP or PNG). |
| iSize | Size of the buffer in bytes. |
| sName | string with the tileset name (max 64 characters). |
| iW | Tile width. If 0 (default), it takes the full image width. |
| iH | Tile height. If 0 (default), it takes the full image height. |
| Sint32 CRM64Pro::TileMgr::remove | ( | const Sint32 | idCDC, |
| const string & | sName ) |
Remove a tile stored in a CDC file.
| idCDC | CDC id. |
| sName | string with the tile name (maximum size of 64 characters). |
| bool CRM64Pro::TileMgr::exist | ( | const Sint32 | idCDC, |
| const string & | sName ) |
Check if a tile is stored in a CDC file.
| idCDC | CDC id. |
| sName | string with the tile name (maximum size of 64 characters). |
| bool CRM64Pro::TileMgr::exist | ( | const string & | sCDCFile, |
| const string & | sName ) |
Check if a tile is stored in a CDC file.
| sCDCFile | Path to the CDC archive file. |
| sName | string with the tile name (maximum size of 64 characters). |