| CRM64Pro GDK v0.16.0 A free cross-platform game development kit built on top of SDL 3.0

Loading...
Searching...
No Matches
CRM64Pro::Scene
Scene module » Scene

Scene class. More...

## Detailed Description

Scene class.

## Public Member Functions
bool | info (Sint32 iMode=-1) override
| Request detailed Scene object information.
const string & | getName () const override
| Get the name.
Uint32 | getID () const override
| Get the ID.
Sint32 | getWidth () const
| Get the total width of the level in pixels.
Sint32 | getHeight () const
| Get the total height of the level in pixels.
Sint32 | getLayerCount (eSceneLayerType eType=SLT_EMPTY) const
| Get the number of allocated layer slots.
eSceneLayerType | getLayerType (Sint32 layer) const
| Get the type of a specific layer.
Sint32 | createLayer (const string &sName, eSceneLayerType eType, Sint32 idLayer=-1, Sint32 iParam1=0, Sint32 iParam2=0)
| Create a new layer.
Sint32 | addLayer (SceneLayer *pLayer, Sint32 idLayer=-1)
| Add an existing layer instance.
bool | closeLayer (Sint32 layer)
| Close and destroy a layer.
bool | clear ()
| Free all resources of current map (layer maps and tilesets).
bool | setViewport (SDL_Rect *rect)
| Set the desired viewport.
bool | getViewport (SDL_Rect *out) const
| Get the current viewport.
bool | setBackgroundColor (Uint32 iRGBA)
| Set background color.
Uint32 | getBackgroundColor () const
| Get background color.
string | getModificationDate () const
| Get the map modification date (last save date).
string | getCreationDate () const
| Get the map creation date (first save date).
Sint32 | createTileSet (Sint32 idRes, Sint32 globalID=-1)
| Create a TileSet from a memory resource (Image or Tile).
Sint32 | createTileSet (const string &sCDCFile, const string &sResourceName, Sint32 globalID=-1)
| Create a TileSet from a CDC archive resource.
Sint32 | createTileSetFromFile (const string &sPath, Sint32 globalID=-1, Sint32 iTileWidth=-1, Sint32 iTileHeight=-1)
| Create a TileSet from a file on disk.
bool | closeTileSet (Sint32 iTN)
| Close and destroy a given TileSet.
Sint32 | getTileResourceID (Sint32 iTN)
| Resolve a Global Tile ID to its internal CRM64Pro Tile Resource ID.
eSceneTileSetType | getTileSetType (Sint32 iTN)
| Get the TileSet type.
bool | getTileSetSource (Sint32 iTN, eSceneStorageMode &eMode, string &sPath, string &sFilename)
| Get the storage metadata for a TileSet.
bool | setTileSetSource (Sint32 iTN, eSceneStorageMode eMode, const string &sPath, const string &sFilename)
| Set the storage metadata for a TileSet.
bool | setLayerFeatures (Sint32 layer, eSceneLayerFeature eLF, bool bEnable)
| Set the layer features.
eSceneLayerFeature | getLayerFeatures (Sint32 layer) const
| Get the layer features.
bool | pause ()
| Pause all active layers.
bool | resume ()
| Resume all active layers.
bool | setLayerAlphaMod (Sint32 layer, Sint32 alpha)
| Set layer alpha modulation used for rendering this layer.
Sint32 | getLayerAlphaMod (Sint32 layer) const
| Get layer alpha modulation.
bool | setLayerParallaxRatio (Sint32 layer, float fPRX, float fPRY)
| Set the layer parallax ratio.
Sint32 | getLayerParallaxRatio (Sint32 layer, float *fPRX, float *fPRY) const
| Get current layer parallax ratio.
bool | setCameraMode (Sint32 iLayer, eSceneCameraMode eMode)
| Set camera mode for a layer.
eSceneCameraMode | getCameraMode (Sint32 iLayer) const
| Get camera mode for a layer.
bool | setCameraParams (Sint32 iLayer, const SceneCameraParams &params)
| Set camera parameters for a layer.
bool | getCameraParams (Sint32 iLayer, SceneCameraParams *pOut) const
| Get camera parameters for a layer.
bool | setCameraTarget (Sint32 iLayer, Sint32 iTargetObjectLayer, Sint32 iTargetObjectID)
| Set camera target by object layer and object ID.
bool | setCameraTarget (Sint32 iLayer, SceneObject *pTarget)
| Set camera target by object pointer.
bool | clearCameraTarget (Sint32 iLayer)
| Clear camera target binding for a layer.
bool | setCameraPosition (Sint32 iLayer, float fX, float fY, bool bDisableNextSmooth=false)
| Set camera absolute position and force manual mode.
bool | setCameraBounds (Sint32 iLayer, const SDL_FRect *pBounds)
| Set optional camera clamp bounds override for a layer.
bool | getCameraBounds (Sint32 iLayer, SDL_FRect *pOut) const
| Get explicit camera clamp bounds override for a layer.
bool | setCameraOffsetCallback (Sint32 iLayer, SCENE_CameraOffsetCallback fnOffset, void *pUserData)
| Set offset callback for ::SCM_OFFSET mode.
bool | setCameraShake (Sint32 iLayer, float amplitudePx, Uint32 durationMs, float falloff=5.0f)
| Set a transient render-only camera shake for a layer.
bool | clearCameraShake (Sint32 iLayer)
| Clear active camera shake on a layer.
Sint32 | setLayerPosition (Sint32 layer, const Position &xpos=Position(PH_KEEP), const Position &ypos=Position(PH_KEEP))
Sint32 | getLayerPosition (Sint32 layer, float *xpos, float *ypos) const
| Get the current layer position (in pixels).
bool | setLayerOnUpdateEnd (Sint32 layer, SCENE_OnLayerCallback myfunc)
| Set an event function (onUpdateEnd) to be called when the engine finishes updating the layer.
SCENE_OnLayerCallback | getLayerOnUpdateEnd (Sint32 layer)
| Get current onUpdateEnd event function if any.
bool | setLayerOnRenderEnd (Sint32 layer, SCENE_OnLayerCallback myfunc)
| Set an event function (onRenderEnd) to be called when the engine finishes rendering the layer.
SCENE_OnLayerCallback | getLayerOnRenderEnd (Sint32 layer)
| Get current onRenderEnd event function if any.
void | setOnTriggerEvent (SceneObject::SCENE_OnTriggerEvent fn, void *pUserData=nullptr)
| Set a global trigger event callback.
bool | getLayerName (Sint32 layer, string &sName) const
| Get the layer name.
bool | setLayerName (Sint32 layer, const string &sName)
| Set a new layer name.
bool | setDebugOverlay (eSceneDebugOverlay eFlags, bool bEnable)
| Enable or disable one or more unified debug overlay flags.
bool | isDebugOverlayEnabled (eSceneDebugOverlay eFlags) const
| Check if all requested debug overlay flags are enabled.
bool | setDebugOverlayColor (eSceneDebugOverlay eFlag, Uint32 iColor)
| Set debug overlay color for a specific overlay flag.
Uint32 | getDebugOverlayColor (eSceneDebugOverlay eFlag) const
| Get debug overlay color for a specific overlay flag.
SceneLayerTile * | accessLayerTile (Sint32 layer)
| Get a tile layer by Scene layer index.
SceneLayerObject * | accessLayerObject (Sint32 layer)
| Get an object layer by Scene layer index.
SceneLayerImage * | accessLayerImage (Sint32 layer)
| Get an image layer by Scene layer index.
bool | screenToWorld (Sint32 sx, Sint32 sy, float *wx, float *wy, Sint32 layer=0) const
| Convert screen coordinates to world coordinates.
bool | screenToCell (Sint32 sx, Sint32 sy, Sint32 *cx, Sint32 *cy, Sint32 layer=0) const
| Convert screen coordinates to tile cell indices.
bool | worldToScreen (float wx, float wy, float *sx, float *sy, Sint32 layer=0)
| Convert world coordinates to screen coordinates.
bool | mouseToWorld (float *wx, float *wy, Sint32 layer=0) const
| Convert current mouse position to world coordinates.
bool | mouseToCell (Sint32 *cx, Sint32 *cy, Sint32 layer=0) const
| Convert current mouse position to tile cell indices.
Sint32 | update (Sint32 layer=0)
| Update status of the Scene.
Sint32 | render (Sint32 layer=0, Sint32 idRes=0)
| Render the 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 | save (const string &sTMXFile, const string &sLevelName="", const string &sCDCFile="", bool bForce=false)
| Save level to native C64SCENE format (TMX-based).
void | setObjectFactory (ISceneObjectFactory *pFactory)
| Set the object factory for creating game objects from Tiled types.
ISceneObjectFactory * | getObjectFactory ()
| Get the current object factory.
bool | isObjectLayer (Sint32 iLayer)
| Check if a layer is an object layer.

## Member Function Documentation

## ◆ save()

Sint32 CRM64Pro::Scene::save | ( | const string & | sTMXFile,
|  | const string & | sLevelName = "",
|  | const string & | sCDCFile = "",
|  | bool | bForce = false )

Save level to native C64SCENE format (TMX-based).

Saves the Scene level to the native C64SCENE format, which is based on Tiled TMX v1.10 (orthogonal, right-down render order). The level can be saved as standalone TMX files on disk or packaged within a CDC archive, with flexible control over TileSet resource locations.

TileSet source handling:

- If bForce=false (default): Resources respect their original storage mode:
  - SSM_DISK: References existing disk file (path/filename preserved)
  - SSM_CDC: References existing CDC archive using "cdc://archive/resource" format
  - SSM_INTERNAL: Always exported to current destination (created from in-memory objects)
- If bForce=true: All resources consolidated to target destination:
  - Saving to disk: All resources exported to same directory as TMX
  - Saving to CDC: All resources packaged into same CDC archive

Output modes:

1. Disk mode (sCDCFile=""): Creates .tmx file and separate .tsx/.png files in sTMXFile directory
2. CDC mode (sCDCFile specified): Packages resources into CDC archive (behavior depends on bForce)

Parameters

  sTMXFile | string containing [directory]+filename+[extension] for the TMX file. Directory separators '\' and '/' are supported. Extension optional.
  sLevelName | Optional level name override. If empty, uses current level name.
  sCDCFile | Optional CDC archive path. If empty, saves as external disk files. If specified, saves to CDC archive (behavior depends on bForce flag).
  bForce | If true, consolidates all resources to target destination (disk or CDC). If false (default), respects original resource storage modes.

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

See also
  load()