Island Game v2 loads a Tiled island, creates the player through an ISceneObjectFactory, builds a runtime movement-cost layer from an image and uses A* to move across the map. It adds a free camera to the simpler v1 example: press C to switch modes, then use the arrow keys to pan.
The callbacks and custom Scene objects share only the Scene, background, debug font, tile size and current camera mode.
Pass the factory while loading so object construction happens as the TMX is parsed. Setup stops if either the load or manager lookup fails.
Layer 1 supplies the grid dimensions and tile size. The custom layer is added at index 5, kept active for pathfinding and hidden until F2 is pressed.
Each tile samples the center of the heightmap image. Black becomes blocked cost 255; brighter pixels produce progressively lower costs, down to 1.
The open set prioritizes total estimated cost. Four cardinal neighbors are accepted when they are inside the map and not marked with cost 255.
When one node is reached, the loop keeps the unused movement budget and continues with the next node. This keeps motion stable at different logic rates.
The player is essential for movement and camera following. The exit remains optional because the rest of the island is still usable without it.
The default camera snaps to the player, centers its target and clamps the viewport to the map bounds.
C selects either snap-follow or manual mode. In manual mode, the arrow keys move layer 1, which acts as the camera anchor for the Scene.
A right-click converts the pointer into a layer-1 cell, starts A* movement and returns the camera to player-follow mode.
Overlapping the exit pauses the Scene while the confirmation dialog is open. Cleanup follows ownership order and is also reused by setup failures.
The tutorial source is authoritative. The following listing is included directly from validation/source/Tutorial_16_Scene_IslandGame_v2.cpp.
#include "CRM64Pro.h"
#include "RunParameter.h"
#define BASEDIR "Base/"
#ifdef CRM64PRO_PLATFORM_WINDOWS
#define OUTPUTDIR "Win64/"
#elif defined(CRM64PRO_PLATFORM_LINUX)
#define OUTPUTDIR "Linux/"
#elif defined(CRM64PRO_PLATFORM_MACOS)
#define OUTPUTDIR "macOS/"
#endif
#define RESOURCE_BG_CDC_NAME "Tutorial_bg"
#define OUTPUT_CDC OUTPUTDIR"Tutorial.cdc"
static const Sint32 iScreenW = 960;
static const Sint32 iScreenH = 540;
static const Sint32 iViewW = 400;
static const Sint32 iViewH = 300;
static const Sint32 iViewX = (iScreenW - iViewW) / 2;
static const Sint32 iViewY = (iScreenH - iViewH) / 2;
static const Sint32 iLogicRate = 20;
static const float fPlayerSpeed = 60.0f;
static const float fCameraPanStep = 5.0f;
struct TutorialState
{
Sint32 idBgImage = -1;
Sint32 idDebugFont = -1;
Sint32 iTileSize = 16;
bool bCameraFollow = true;
};
static TutorialState* g_pState = nullptr;
{
public:
SceneLayerHeightMap(
const string& sName, Sint32 iH, Sint32 iW) :
SceneLayerTile(sName, iH, iW)
{
}
{
if(!g_pState) return 0;
if(!pFont) return 0;
for(Sint32 iLY = mVR.iCYStart; iLY < mVR.iCYEnd; iLY++)
{
if(iLY < 0 || iLY >= getHeight()) continue;
float fScreenY = rContext.
worldToScreen(0.0f,
static_cast<float>(iLY * mVR.iTileH),
true).y;
for(Sint32 iLX = mVR.iCXStart; iLX < mVR.iCXEnd; iLX++)
{
if(iLX < 0 || iLX >= getWidth()) continue;
Uint32 iWeight = iCellMap[iLY][iLX];
if(iWeight == 0) continue;
float fScreenX = rContext.
worldToScreen(
static_cast<float>(iLX * mVR.iTileW), 0.0f,
true).x;
char szBuf[16];
if(iWeight == 255) snprintf(szBuf, 16, "X");
else snprintf(szBuf, 16, "%u", static_cast<unsigned int>(iWeight));
pFont->
setPosition(fScreenX + (mVR.iTileW - iFW) / 2, fScreenY + (mVR.iTileH - iFH) / 2);
}
}
return 0;
}
};
struct Node
{
Sint32 iX, iY;
float fF;
bool operator<(const Node& rOther) const
{
return fF > rOther.fF;
}
};
{
public:
static Sint32 iIDSpriteShared;
Sint32 iIDSprite;
bool bIsMoving;
vector<SDL_Point> vPath;
Sint32 iCurrentPathIndex;
Player() : iIDSprite(-1), bIsMoving(false), iCurrentPathIndex(0) {
}
void initialize() override
{
setSize(32.0f, 32.0f);
setPosition(getX() - 16.0f, getY() - 32.0f);
if(iIDSpriteShared < 0)
{
ImageMgr& mImageMgr = Main::instance().imageMgr();
SpriteMgr& mSpriteMgr = Main::instance().spriteMgr();
string sSprName = "PlayerSprite";
iIDSpriteShared = mSpriteMgr.
create(sSprName);
if(iIDSpriteShared >= 0)
{
Sint32 idImg = mImageMgr.
loadFromFile(BASEDIR
"sprite2.png");
if(idImg > 0)
{
Sprite* pSpr = mSpriteMgr.
get(iIDSpriteShared);
}
}
}
iIDSprite = iIDSpriteShared;
}
void updateMovement(float fDeltaTime)
{
Sprite* pS = Main::instance().spriteMgr().get(iIDSprite);
if(!bIsMoving || vPath.empty())
{
return;
}
float fStepRemaining = fPlayerSpeed * fDeltaTime;
const float fEpsilon = 0.0001f;
while(bIsMoving && !vPath.empty() && iCurrentPathIndex < (int)vPath.size() && fStepRemaining > fEpsilon)
{
float fNextWorldX = (float)(vPath[iCurrentPathIndex].x * g_pState->iTileSize) + (g_pState->iTileSize * 0.5f) - 16.0f;
float fNextWorldY = (float)(vPath[iCurrentPathIndex].y * g_pState->iTileSize) + (float)g_pState->iTileSize - 32.0f;
float fDiffX = fNextWorldX - getX();
float fDiffY = fNextWorldY - getY();
const bool bMostlyHorizontal = fabsf(fDiffX) >= fabsf(fDiffY);
if(bMostlyHorizontal) fDiffY = 0.0f;
else fDiffX = 0.0f;
float fDist = sqrtf(fDiffX * fDiffX + fDiffY * fDiffY);
if(fDist <= fEpsilon)
{
iCurrentPathIndex++;
continue;
}
if(fDist <= fStepRemaining)
{
setPosition(fNextWorldX, fNextWorldY);
fStepRemaining -= fDist;
iCurrentPathIndex++;
if(iCurrentPathIndex >= (int)vPath.size())
{
bIsMoving = false;
vPath.clear();
return;
}
continue;
}
float fMoveX = (fDiffX / fDist) * fStepRemaining;
float fMoveY = (fDiffY / fDist) * fStepRemaining;
float fNewX = getX() + fMoveX;
float fNewY = getY() + fMoveY;
if(bMostlyHorizontal) fNewY = fNextWorldY;
else fNewX = fNextWorldX;
setPosition(fNewX, fNewY);
fStepRemaining = 0.0f;
if(pS)
{
{
}
}
}
}
void update(Scene*, SceneLayerContext& rContext) override
{
}
void render(Scene* pScene, SceneLayerContext& rContext) override
{
if(iIDSprite < 0) return;
Sprite* pSpr = Main::instance().spriteMgr().get(iIDSprite);
if(!pSpr) return;
SDL_FPoint pScreen = rContext.
worldToScreen(getX(), getY(),
true);
float fScreenX = pScreen.x;
float fScreenY = pScreen.y;
if(rContext.data.Object.bRenderStateValid && rContext.data.Object.pObject == this)
{
fScreenX = rContext.data.Object.fScreenX;
fScreenY = rContext.data.Object.fScreenY;
}
}
void moveTo(Sint32 iGridX, Sint32 iGridY);
};
Sint32 Player::iIDSpriteShared = -1;
{
public:
SceneObject* create(const string& rType) override
{
if(rType == "start")
{
return new(std::nothrow) Player();
}
return nullptr;
}
};
void Player::moveTo(Sint32 iEndX, Sint32 iEndY)
{
if(!g_pState || !g_pState->pScene) return;
if(!pMap) return;
Sint32 iStartX = (Sint32)((getX() + getWidth() * 0.5f) / static_cast<float>(g_pState->iTileSize));
Sint32 iStartY = (Sint32)((getY() + getHeight() - 1.0f) / static_cast<float>(g_pState->iTileSize));
if(iStartX < 0 || iStartX >= iWidth || iStartY < 0 || iStartY >= iHeight) return;
if(iEndX < 0 || iEndX >= iWidth || iEndY < 0 || iEndY >= iHeight) return;
if(pMap->
iCellMap[iEndY][iEndX] == 255)
return;
priority_queue<Node> vOpenSet;
vector<vector<float>> vvfCostSoFar(iHeight, vector<float>(iWidth, -1.0f));
vector<vector<SDL_Point>> vvCameFrom(iHeight, vector<SDL_Point>(iWidth, { -1, -1 }));
vOpenSet.push({ iStartX, iStartY, 0.0f });
vvfCostSoFar[iStartY][iStartX] = 0.0f;
const Sint32 iDirs[4][2] = { {0,1}, {1,0}, {0,-1}, {-1,0} };
while(!vOpenSet.empty())
{
Node mCurrent = vOpenSet.top();
vOpenSet.pop();
if(mCurrent.iX == iEndX && mCurrent.iY == iEndY) break;
for(auto& rDir : iDirs)
{
Sint32 iNX = mCurrent.iX + rDir[0];
Sint32 iNY = mCurrent.iY + rDir[1];
if(iNX >= 0 && iNX < iWidth && iNY >= 0 && iNY < iHeight)
{
Uint32 iWeight = pMap->
iCellMap[iNY][iNX];
if(iWeight == 255) continue;
float fDist = 1.0f;
float fNewCost = vvfCostSoFar[mCurrent.iY][mCurrent.iX] + (fDist * (float)iWeight);
if(vvfCostSoFar[iNY][iNX] == -1.0f || fNewCost < vvfCostSoFar[iNY][iNX])
{
vvfCostSoFar[iNY][iNX] = fNewCost;
float fPriority = fNewCost + (abs(iEndX - iNX) + abs(iEndY - iNY));
vOpenSet.push({ iNX, iNY, fPriority });
vvCameFrom[iNY][iNX] = { mCurrent.iX, mCurrent.iY };
}
}
}
}
vPath.clear();
if(vvCameFrom[iEndY][iEndX].x != -1)
{
SDL_Point mCurr = { iEndX, iEndY };
while(mCurr.x != iStartX || mCurr.y != iStartY)
{
vPath.push_back(mCurr);
mCurr = vvCameFrom[mCurr.y][mCurr.x];
}
reverse(vPath.begin(), vPath.end());
iCurrentPathIndex = 0;
bIsMoving = true;
}
}
bool setupTutorial()
{
if(!g_pState) return false;
static TutorialObjectFactory Factory;
string sTMX = BASEDIR "tiled/rpg/island.tmx";
if(idScene < 0)
{
mLog.msg(
LL_CRITICAL,
"Failed to load TMX: %s\n", sTMX.c_str());
return false;
}
if(!g_pState->pScene) return false;
if(!pLayer1)
{
mLog.msg(
LL_ERROR,
"Required tile layer 1 was not found.\n");
return false;
}
const Sint32 iMapW = pLayer1->
getWidth();
if(iMapW <= 0 || iMapH <= 0 || g_pState->iTileSize <= 0)
{
mLog.msg(
LL_ERROR,
"Tile layer 1 has invalid dimensions.\n");
return false;
}
SceneLayerHeightMap* pLayerHM = new(std::nothrow) SceneLayerHeightMap("HeightMap", iMapH, iMapW);
if(!pLayerHM)
{
mLog.msg(
LL_ERROR,
"Failed to allocate the heightmap layer.\n");
return false;
}
if(!pLayerHM->setCellWidth(g_pState->iTileSize) ||
!pLayerHM->setCellHeight(g_pState->iTileSize))
{
delete pLayerHM;
mLog.msg(
LL_ERROR,
"Failed to configure the heightmap cell size.\n");
return false;
}
if(g_pState->pScene->addLayer(pLayerHM, 5) < 0)
{
delete pLayerHM;
mLog.msg(
LL_ERROR,
"Failed to add the heightmap layer.\n");
return false;
}
if(!g_pState->pScene->setLayerFeatures(5,
SLF_UPDATE,
true) ||
!g_pState->pScene->setLayerFeatures(5,
SLF_RENDER,
false) ||
!g_pState->pScene->setLayerAlphaMod(5, 128))
{
mLog.msg(
LL_ERROR,
"Failed to configure the heightmap layer.\n");
return false;
}
string sHMFile = BASEDIR "tiled/rpg/island-heightmap.png";
if(idImgH <= 0)
{
mLog.msg(
LL_ERROR,
"Failed to load Heightmap image: %s\n", sHMFile.c_str());
return false;
}
SDL_Surface* sH = pHeightImage ? pHeightImage->
getSurface() :
nullptr;
if(!sH || sH->w <= 0 || sH->h <= 0)
{
mLog.msg(
LL_ERROR,
"Failed to access Heightmap image pixels.\n");
return false;
}
for(Sint32 iY = 0; iY < iMapH; iY++)
{
for(Sint32 iX = 0; iX < iMapW; iX++)
{
Sint32 iPX = iX * g_pState->iTileSize + (g_pState->iTileSize / 2);
Sint32 iPY = iY * g_pState->iTileSize + (g_pState->iTileSize / 2);
if(iPX >= sH->w) iPX = sH->w - 1;
if(iPY >= sH->h) iPY = sH->h - 1;
Uint8 iR = 0, iG = 0, iB = 0, iA = 0;
if(!SDL_ReadSurfacePixel(sH, iPX, iPY, &iR, &iG, &iB, &iA))
{
mLog.msg(
LL_ERROR,
"Failed to read Heightmap image pixels.\n");
return false;
}
const Sint32 iBrightness = (iR + iG + iB) / 3;
Uint32 iWeight = 255;
if(iBrightness > 10)
{
iWeight = 255 - iBrightness;
if(iWeight < 1) iWeight = 1;
}
pLayerHM->setCellValue(iY, iX, iWeight);
}
}
return true;
}
Sint32 renderWrapper(Sint32)
{
if(!g_pState || !g_pState->pScene) return 0;
if(g_pState->idBgImage > 0)
{
}
g_pState->pScene->render();
return 0;
}
static void closeTutorial()
{
}
int main(int argc, char* argv[])
{
if(!runParameterReadRender(argc, argv, eRenderer)) return 1;
TutorialState state;
g_pState = &state;
{
return -1;
}
pScreen->
setSize(iScreenW, iScreenH);
pScreen->
setTitle(
"Tutorial 16 Scene - Island Game v2");
{
return -1;
}
{
return -1;
}
g_pState->idBgImage = mC64.
imageMgr().
load(OUTPUT_CDC, RESOURCE_BG_CDC_NAME);
if(g_pState->idBgImage <= 0 || g_pState->idDebugFont <= 0)
{
closeTutorial();
return -1;
}
if(!setupTutorial())
{
closeTutorial();
return -1;
}
Player* pPlayer = nullptr;
if(g_pState->pScene->isObjectLayer(3))
{
if(pLayerObj)
{
}
}
if(!pPlayer)
{
closeTutorial();
return -1;
}
if(!pExit)
{
}
bool bShowGrid = false;
bool bShowWeights = false;
bool bSmoothScroll = true;
SDL_Rect rView = { iViewX, iViewY, iViewW, iViewH };
if(!g_pState->pScene->setViewport(&rView))
{
closeTutorial();
return -1;
}
mC64.
logMgr().
get()->
msg(
LL_INFO,
"Init: Viewport set to [%d, %d, %d, %d]\n", rView.x, rView.y, rView.w, rView.h);
if(!g_pState->pScene->setCameraTarget(1, pPlayer) ||
!g_pState->pScene->setCameraParams(1, mCam) ||
!g_pState->pScene->setCameraMode(1,
SCM_SNAP))
{
closeTutorial();
return -1;
}
for(Sint32 i = 1; i <= 4; i++)
{
{
closeTutorial();
return -1;
}
}
mC64.
logMgr().
get()->
msg(
LL_INFO,
"\nCONTROLS:\n [Right-Click] Move\n [Cursors] Scroll with Camera mode\n [C] Switch to Camera mode\n [S] Toggle smooth scroll\n [F1] Toggle grid\n [F2] Toggle weights\n [Q/Esc] Quit\n\n");
SDL_Event ev;
bool bDone = false;
while(!bDone)
{
{
if(ev.type == SDL_EVENT_QUIT) bDone = true;
if(ev.type == SDL_EVENT_KEY_DOWN)
{
if(ev.key.key == SDLK_ESCAPE || ev.key.key == SDLK_Q) bDone = true;
if(ev.key.key == SDLK_C)
{
g_pState->bCameraFollow = !g_pState->bCameraFollow;
if(g_pState->bCameraFollow)
{
if(pPlayer) g_pState->pScene->setCameraTarget(1, pPlayer);
g_pState->pScene->setCameraMode(1,
SCM_SNAP);
}
else
{
}
}
if(ev.key.key == SDLK_F1)
{
bShowGrid = !bShowGrid;
}
if(ev.key.key == SDLK_F2)
{
bShowWeights = !bShowWeights;
g_pState->pScene->setLayerFeatures(5,
SLF_RENDER, bShowWeights);
}
if(ev.key.key == SDLK_S)
{
bSmoothScroll = !bSmoothScroll;
for(Sint32 i = 1; i <= 4; i++) g_pState->pScene->setLayerFeatures(i,
SLF_SMOOTHSCROLL, bSmoothScroll);
}
}
}
if(bDone) break;
if((iMouseB & SDL_BUTTON_MASK(SDL_BUTTON_RIGHT)) && !(iMousePrev & SDL_BUTTON_MASK(SDL_BUTTON_RIGHT)) && pPlayer)
{
Sint32 iGX = 0;
Sint32 iGY = 0;
if(g_pState->pScene->mouseToCell(&iGX, &iGY, 1))
{
pPlayer->moveTo(iGX, iGY);
g_pState->bCameraFollow = true;
g_pState->pScene->setCameraTarget(1, pPlayer);
g_pState->pScene->setCameraMode(1,
SCM_SNAP);
}
}
float fWX = 0.0f, fWY = 0.0f;
vector<SceneObject*> vHits;
if(g_pState->pScene->screenToWorld((Sint32)fMX, (Sint32)fMY, &fWX, &fWY, 3))
{
vector<SceneObject*> vQuery;
if(pLayerObj) pLayerObj->
queryRegion(fWX, fWY, 1.0f, 1.0f, vQuery);
for(auto* pObj : vQuery)
{
if(pObj->containsPoint(fWX, fWY)) vHits.push_back(pObj);
}
}
if((iMouseB & SDL_BUTTON_MASK(SDL_BUTTON_LEFT)) && !(iMousePrev & SDL_BUTTON_MASK(SDL_BUTTON_LEFT)))
{
if(!vHits.empty())
{
}
}
g_pState->pScene->update();
if(!g_pState->bCameraFollow)
{
float fDX = 0.0f;
float fDY = 0.0f;
if(mC64.
getKeyState(SDLK_RIGHT)) fDX += fCameraPanStep;
if(fDX != 0.0f || fDY != 0.0f)
{
float fX = 0.0f, fY = 0.0f;
if(g_pState->pScene->getLayerPosition(1, &fX, &fY) >= 0)
{
}
}
}
if(pPlayer && pExit && pPlayer->overlapsObject(pExit))
{
pPlayer->bIsMoving = false;
pPlayer->vPath.clear();
g_pState->pScene->pause();
{
bDone = true;
}
else
{
pPlayer->setPosition(pPlayer->getX(), pPlayer->getY() + 32.0f);
}
g_pState->pScene->resume();
}
}
g_pState->pScene->save(OUTPUTDIR"islandgame_v2.tmx", "", "islandgame.cdc", true);
closeTutorial();
return 0;
}
Screen * get(Sint32 idScreen=0)
Get a pointer to the screen using its handle.
Definition CoreConfig.cpp:1497
void setMTFriendly(Uint8 iDelayMS)
Set the multithread-friendly scheduler yield.
Definition CoreConfig.cpp:1183
Sint32 getButtonsPrev() const
Get the previous mouse buttons.
Definition GraphicsCursor.cpp:1053
float getY() const
Get the mouse cursor Y position.
Definition GraphicsCursor.cpp:1041
Sint32 select(Sint32 idCursor)
Select a mouse cursor.
Definition GraphicsCursor.cpp:968
Sint32 getButtons() const
Get the mouse buttons.
Definition GraphicsCursor.cpp:1047
float getX() const
Get the mouse cursor X position.
Definition GraphicsCursor.cpp:1035
Font Object class.
Definition CRM64Pro.h:4741
Sint32 getHeight() const
Get the height of this font (in pixels).
Definition GraphicsFont.cpp:1025
Sint32 render(const string &sText, bool bShowCursor=false, Sint32 iCurPos=-1, Sint32 idRes=0)
Render a text using this font.
Definition GraphicsFont.cpp:1095
bool setPosition(const Position &rPosX, const Position &rPosY, bool bInterpolate=false)
Set the font position.
Definition GraphicsFont.cpp:1037
Sint32 getWidth(const string &sText, Sint32 iCurPos=-1) const
Get the width of the given string (in pixels).
Definition GraphicsFont.cpp:987
Sint32 getBuiltin(const string &sName)
Get a built-in embedded font id using its name.
Definition GraphicsFont.cpp:1436
Sint32 close(Sint32 idFont) override
Close and destroy a font.
Definition GraphicsFont.cpp:1363
Factory interface for creating game objects from Tiled type strings.
Definition CRM64Pro.h:10711
Image Object class.
Definition CRM64Pro.h:3356
SDL_Surface * getSurface()
Get the raw source surface of this image.
Definition GraphicsImage.cpp:1827
Sint32 render(Sint32 idRes=0, SDL_FRect *pSrc=nullptr, SDL_FRect *pDst=nullptr)
Render the image.
Definition GraphicsImage.cpp:1575
Image * get(Sint32 idImg)
Get a pointer to the image using its handle.
Definition GraphicsImage.cpp:2279
Sint32 loadFromFile(const string &sFile, const string &sName="")
Load an image from an external file (BMP, PNG, JPG, PCX, TGA or WebP formats).
Definition GraphicsImage.cpp:2434
Sint32 load(const string &sCDCFile, const string &sName)
Load an image stored in a CDC file.
Definition GraphicsImage.cpp:2476
Sint32 close(Sint32 idImg) override
Close and destroy an image.
Definition GraphicsImage.cpp:2178
Log Object class.
Definition CRM64Pro.h:771
CRM64Pro GDK Main class.
Definition CRM64Pro.h:502
Scene class.
Definition CRM64Pro.h:11200
Object layer containing game objects with spatial partitioning.
Definition CRM64Pro.h:10986
TileLayer class for tile-based map layers.
Definition CRM64Pro.h:10368
Uint32 ** iCellMap
Direct mutable 2D cell map.
Definition CRM64Pro.h:10571
Sint32 loadFromFile(const string &sTMXFile, ISceneObjectFactory *pFactory=nullptr)
Load a level from a TMX file.
Definition SceneMapLoad.cpp:1575
Base class for all Scene game objects.
Definition CRM64Pro.h:10725
Screen Object class.
Definition CRM64Pro.h:1055
Sint32 show()
Show the screen.
Definition CoreConfig.cpp:362
Sint32 setDriver(eConfigRendererDriver eCRD)
Set the renderer driver.
Definition CoreConfig.cpp:454
bool setRenderCallback(RenderCallback fnCallback)
Set a callback function for rendering graphics at Render Frame Rate.
Definition CoreConfig.cpp:765
Sint32 setSize(Sint32 iWidth, Sint32 iHeight)
Set the size of the screen.
Definition CoreConfig.cpp:526
bool setTitle(const string &sName)
Set the title.
Definition CoreConfig.cpp:674
Sprite Object class.
Definition CRM64Pro.h:4262
void setStatsLevel(eMemStatsLevel eMSL)
Set the memory stats gathering level.
Definition CMemoryManager.cpp:618
void destroy()
Releases the internal heap and displays final stats.
Definition CMemoryManager.cpp:954
@ MSL_HIGH
MSL_NORMAL plus deallocations and sizes logging for each module.
Definition CRM64Pro.h:387
eConfigRendererDriver
Screen renderer drivers.
Definition CRM64Pro.h:1013
@ CRD_SOFTWARE
Screen::setDriver(): software renderer driver. Slow but works on all platforms.
Definition CRM64Pro.h:1015
bool msg(eLogLevel eLL, const char *szFmt,...)
Write a message to the log.
Definition CoreLog.cpp:448
Log * get(Sint32 idLog=0)
Get a pointer to the log object.
Definition CoreLog.cpp:921
bool init(const string &sAppname, eLogLevel eLL, eLogMode eLM, const string &sFilename="", const string &sAuthor="", const string &sEmail="", const string &sWeb="")
Initialize the log object.
Definition CoreLog.cpp:338
@ LM_FILE
Log output mode for the 'lm' parameter in CRM64Pro::Log::init(). Output to a file and overwrite exist...
Definition CRM64Pro.h:748
@ LM_STDOUT
Log output mode for the 'lm' parameter in CRM64Pro::Log::init(). Output to standard output (stdout).
Definition CRM64Pro.h:750
@ LL_INFO
Runtime events (startup/shutdown). Messages without timestamp.
Definition CRM64Pro.h:764
@ LL_CRITICAL
Fatal errors, application crash, or assertions.
Definition CRM64Pro.h:761
@ LL_ERROR
Runtime errors that do not require immediate termination.
Definition CRM64Pro.h:762
SpriteMgr & spriteMgr()
Get reference to Sprite Manager.
Definition CoreMain.cpp:772
Timer & timer()
Get reference to Timer module.
Definition CoreMain.cpp:730
Sint32 update(SDL_Event *evUser=nullptr)
Manage the GDK update cycle with a fixed virtual logic frame rate.
Definition CoreMain.cpp:451
ImageMgr & imageMgr()
Get reference to Image Manager.
Definition CoreMain.cpp:754
CursorMgr & cursorMgr()
Get reference to Cursor Manager.
Definition CoreMain.cpp:760
SceneMgr & sceneMgr()
Get reference to Scene Manager.
Definition CoreMain.cpp:814
static void terminate()
Main explicit destructor.
Definition CoreMain.cpp:266
static Main & instance()
Access the Main singleton.
Definition CoreMain.cpp:252
LogMgr & logMgr()
Get reference to Log Manager.
Definition CoreMain.cpp:724
Tool & tool()
Get reference to Tool module.
Definition CoreMain.cpp:718
bool getKeyState(SDL_Keycode keycode) const
Get the current state of a key.
Definition CoreMain.cpp:686
FontMgr & fontMgr()
Get reference to Font Manager.
Definition CoreMain.cpp:778
ConfigMgr & configMgr()
Get reference to Config Manager.
Definition CoreMain.cpp:712
eSceneLayerFeature getLayerFeatures(Sint32 iLayer) const
Get the layer features.
Definition Scene.cpp:810
@ SCM_MANUAL
Manual mode. Camera is controlled only through setLayerPosition()/setCameraPosition().
Definition CRM64Pro.h:10181
@ SCM_SNAP
Instant target tracking each logic tick (no damping, no deadzone behavior).
Definition CRM64Pro.h:10183
@ SLF_RENDER
Enable the rendering feature. Enabling this flag also enables SLF_UPDATE. Disabling render does not d...
Definition CRM64Pro.h:10079
@ SLF_SMOOTHSCROLL
Enable the smooth rendering feature. Check render() for further details.
Definition CRM64Pro.h:10080
@ SLF_UPDATE
Enable the updating feature. Check update() for further details.
Definition CRM64Pro.h:10078
@ SDO_TILE_CELLGRID
Draw tile cell grid overlays for rendered tile layers.
Definition CRM64Pro.h:10097
const string & getType() const
Get the type identifier.
Definition SceneLayerObject.cpp:1505
SceneObject * findFirstByType(const string &sType)
Find first object matching an exact type string.
Definition SceneLayerObject.cpp:3349
const string & getName() const
Get the object name.
Definition SceneLayerObject.cpp:1510
void queryRegion(float fX, float fY, float fW, float fH, vector< SceneObject * > &vResults)
Query objects whose AABB overlaps a region.
Definition SceneLayerObject.cpp:3285
Sint32 getHeight() const
Get map height.
Definition SceneLayerTile.cpp:101
Sint32 getCellWidth() const
Get cell width.
Definition SceneLayerTile.cpp:92
Sint32 getWidth() const
Get map width.
Definition SceneLayerTile.cpp:98
Sint32 close(Sint32 idScene) override
Close and destroy a Scene.
Definition Scene.cpp:2298
bool info(Sint32 iMode=0) override
Request Scene Manager information.
Definition Scene.cpp:2215
Scene * get(Sint32 idScene)
Get a pointer to the Scene using its handle.
Definition Scene.cpp:2355
eGeneralStatus status() const
Get the sprite status.
Definition GraphicsSprite.cpp:749
Sint32 assignImage(Sint32 idImage, Sint32 iOwnership=0)
Assign an Image to this sprite.
Definition GraphicsSprite.cpp:494
Sint32 render(Sint32 idRes=0)
Render the sprite.
Definition GraphicsSprite.cpp:1395
#define SPR_STATE_RIGHT
Definition CRM64Pro.h:4246
bool setAnimStateIndex(Sint32 iIndex, Uint16 iState)
Set the animation state by index.
Definition GraphicsSprite.cpp:927
bool selectAnim(Uint16 iState)
Select an animation by state.
Definition GraphicsSprite.cpp:794
bool pause()
Pause the sprite animation.
Definition GraphicsSprite.cpp:735
#define SPR_STATE_DOWN
Definition CRM64Pro.h:4242
bool setPosition(float fX, float fY, bool bInterpolate=false)
Set the sprite position.
Definition GraphicsSprite.cpp:1356
bool resume()
Resume from a previous paused sprite animation.
Definition GraphicsSprite.cpp:742
Sint32 create(const string &sName, Uint32 iVersion=10) override
Create a new sprite.
Definition GraphicsSprite.cpp:1691
Sint32 getAnimCurrent() const
Get current animation state.
Definition GraphicsSprite.cpp:781
bool setOffset(Sint32 iX, Sint32 iY)
Set the sprite offsets for creating the animations and frames.
Definition GraphicsSprite.cpp:640
#define SPR_STATE_UP
Definition CRM64Pro.h:4240
Sprite * get(Sint32 idSprite)
Get a pointer to the sprite using its handle.
Definition GraphicsSprite.cpp:1843
#define SPR_STATE_LEFT
Definition CRM64Pro.h:4244
bool setFrameTimeIndex(Sint32 iIndex, Sint32 iFrame, Uint16 iTime)
Set the frame time duration by index.
Definition GraphicsSprite.cpp:1284
Sint32 close(Sint32 idSprite) override
Close and destroy a sprite.
Definition GraphicsSprite.cpp:1739
bool init(eTimerState eState=TS_INIT)
Initialize the timer system.
Definition CoreTimer.cpp:543
bool setRate(Uint16 iR, Uint16 iL)
Set preferred Render and Logic Frame Rate.
Definition CoreTimer.cpp:556
CRM64Pro GDK.
Definition AudioTrack.cpp:36
Absolute coordinate or helper-relative position used by layout APIs.
Definition CRM64Pro.h:346
Camera configuration parameters.
Definition CRM64Pro.h:10194
SDL_FPoint ptScreenAnchor
Normalized viewport anchor [0..1]x[0..1] where the target anchor should appear on screen....
Definition CRM64Pro.h:10200
SDL_FPoint ptTargetAnchor
Normalized target anchor [0..1]x[0..1] on the followed object (0,0=top-left, 0.5,1....
Definition CRM64Pro.h:10199
float fDamping
Target-following exponential damping strength in 1/second. Ignored by SCM_AUTOSCROLL....
Definition CRM64Pro.h:10197
bool bClampToBounds
If true, clamp camera to explicit camera bounds (if set) or to layer/world bounds....
Definition CRM64Pro.h:10198
Layer Context structure.
Definition CRM64Pro.h:10223
float fScrollY
Current Logic/Render Y scroll position.
Definition CRM64Pro.h:10228
SDL_Rect rViewport
The effective viewport used for this frame.
Definition CRM64Pro.h:10226
SDL_FPoint worldToScreen(float fWorldX, float fWorldY, bool bQuantize=true) const
Convert world coordinates to screen coordinates using the canonical render camera.
Definition CRM64Pro.h:10273
float fDeltaTime
Time elapsed since last frame (for update). 0 during render.
Definition CRM64Pro.h:10230
float fScrollX
Current Logic/Render X scroll position.
Definition CRM64Pro.h:10227