![]() |
CRM64Pro GDK v0.18.0
A free cross-platform game development kit built on top of SDL 3.0
|
Scene class.
Public Member Functions | |
| bool | info (Sint32 iMode=0) override |
| Request detailed Scene object information. | |
| const string & | getName () const override |
| Get the name. | |
| Sint32 | 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 iLayer) 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 iLayer) |
| Close and destroy a layer. | |
| bool | clear () |
| Free all resources of current map (layer maps and tilesets). | |
| bool | setViewport (SDL_Rect *pRect) |
| Set the desired viewport. | |
| bool | getViewport (SDL_Rect *pOut) 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. | |
| Sint32 | setTileAnimation (Uint32 iTileGID, const vector< Uint32 > &vFrameGID, const vector< Sint32 > &vDuration) |
| Set a TileSet animation for a tile. | |
| Sint32 | clearTileAnimation (Uint32 iTileGID) |
| Clear a TileSet animation from a tile. | |
| 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 iLayer, eSceneLayerFeature eLF, bool bEnable) |
| Set the layer features. | |
| eSceneLayerFeature | getLayerFeatures (Sint32 iLayer) const |
| Get the layer features. | |
| bool | pause () |
| Pause all active layers. | |
| bool | resume () |
| Resume all active layers. | |
| bool | setLayerAlphaMod (Sint32 iLayer, Sint32 iAlpha) |
| Set layer alpha modulation used for rendering this layer. | |
| Sint32 | getLayerAlphaMod (Sint32 iLayer) const |
| Get layer alpha modulation. | |
| bool | setLayerParallaxRatio (Sint32 iLayer, float fPRX, float fPRY) |
| Set the layer parallax ratio. | |
| Sint32 | getLayerParallaxRatio (Sint32 iLayer, 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 &rParams) |
| Set camera parameters for a layer. | |
| bool | getCameraParams (Sint32 iLayer, SceneCameraParams *pOut) const |
| Get camera parameters for a layer. | |
| bool | setCameraTarget (Sint32 iLayer, Sint32 idTargetObjectLayer, Sint32 idTargetObject) |
| 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, SceneCameraOffsetCallback fnCallback) |
| Set offset callback for ::SCM_OFFSET mode. | |
| bool | setCameraShake (Sint32 iLayer, float fAmplitudePX, Uint32 iDurationMS, float fFalloff=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 iLayer, const Position &rPosX=Position(PH_KEEP), const Position &rPosY=Position(PH_KEEP), bool *bMoved=nullptr) |
| Set the layer absolute position (in pixels). | |
| Sint32 | getLayerPosition (Sint32 iLayer, float *fX, float *fY) const |
| Get the current layer position (in pixels). | |
| bool | setLayerOnUpdateEnd (Sint32 iLayer, SceneLayerCallback fnCallback) |
| Set an event function (onUpdateEnd) to be called when the engine finishes updating the layer. | |
| SceneLayerCallback | getLayerOnUpdateEnd (Sint32 iLayer) const |
| Get current onUpdateEnd event function if any. | |
| bool | setLayerOnRenderEnd (Sint32 iLayer, SceneLayerCallback fnCallback) |
| Set an event function (onRenderEnd) to be called when the engine finishes rendering the layer. | |
| SceneLayerCallback | getLayerOnRenderEnd (Sint32 iLayer) const |
| Get current onRenderEnd event function if any. | |
| void | setOnTriggerEvent (SceneObject::TriggerEventCallback fnCallback) |
| Set a global trigger event callback. | |
| bool | getLayerName (Sint32 iLayer, string &sName) const |
| Get the layer name. | |
| bool | setLayerName (Sint32 iLayer, 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 iLayer) |
| Get a tile layer by Scene layer index. | |
| SceneLayerObject * | accessLayerObject (Sint32 iLayer) |
| Get an object layer by Scene layer index. | |
| SceneLayerImage * | accessLayerImage (Sint32 iLayer) |
| Get an image layer by Scene layer index. | |
| bool | screenToWorld (Sint32 iScreenX, Sint32 iScreenY, float *fWorldX, float *fWorldY, Sint32 iLayer=0) const |
| Convert screen coordinates to world coordinates. | |
| bool | screenToCell (Sint32 iScreenX, Sint32 iScreenY, Sint32 *iCellX, Sint32 *iCellY, Sint32 iLayer=0) const |
| Convert screen coordinates to tile cell indices. | |
| bool | worldToScreen (float fWorldX, float fWorldY, float *fScreenX, float *fScreenY, Sint32 iLayer=0) |
| Convert world coordinates to screen coordinates. | |
| bool | mouseToWorld (float *fWorldX, float *fWorldY, Sint32 iLayer=0) const |
| Convert current mouse position to world coordinates. | |
| bool | mouseToCell (Sint32 *iCellX, Sint32 *iCellY, Sint32 iLayer=0) const |
| Convert current mouse position to tile cell indices. | |
| Sint32 | update (Sint32 iLayer=0) |
| Update status of the Scene. | |
| Sint32 | render (Sint32 iLayer=0, Sint32 idRes=0) |
| Render the visible layers. | |
| Sint32 | importLayerFromFile (Sint32 iLayer, const string &sFile, const string &sLayerName, Sint32 iTileSizeX, Sint32 iTileSizeY, float fMaxDevPercentage=100.0, Sint32 iCK=-1) |
| Import an image file (BMP or PNG) into a layer. | |
| Sint32 | importLayerFromImage (Sint32 iLayer, Sint32 idImg, const string &sLayerName, Sint32 iTileSizeX, Sint32 iTileSizeY, float fMaxDevPercentage=100.0, Sint32 iCK=-1) |
| Import an image into a layer. | |
| Sint32 | exportLayerToFile (Sint32 iLayer, const string &sFile) |
| Export a layer to an external PNG image. | |
| Sint32 | exportLayerToImage (Sint32 iLayer, 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). | |
| Sint32 | saveToBuffer (Uint8 *&pBuffer, Sint32 &iSize, const string &sTMXFile, const string &sLevelName="", const string &sCDCFile="", bool bForce=false) |
| Save level to a TMX memory buffer. | |
| void | setObjectFactory (ISceneObjectFactory *pFactory) |
| Set the object factory for creating game objects from Tiled types. | |
| ISceneObjectFactory * | getObjectFactory () const |
| Get the current object factory. | |
| bool | isObjectLayer (Sint32 iLayer) const |
| Check if a layer is an object layer. | |
| 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:
Output modes:
| 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. |
| Sint32 CRM64Pro::Scene::saveToBuffer | ( | Uint8 *& | pBuffer, |
| Sint32 & | iSize, | ||
| const string & | sTMXFile, | ||
| const string & | sLevelName = "", | ||
| const string & | sCDCFile = "", | ||
| bool | bForce = false ) |
Save level to a TMX memory buffer.
| pBuffer | Output owned buffer. Previous content is not freed. Must be released with CMem::free(). |
| iSize | output buffer size in bytes. |
| sTMXFile | string containing [directory]+filename+[extension] for the TMX file. |
| sLevelName | Optional level name override. If empty, uses current level name. |
| sCDCFile | Optional CDC archive path used to build CDC resource references. |
| bForce | If true, consolidates resource references to the target destination without writing side resources. |