scerne stuff

This commit is contained in:
2025-10-01 19:21:20 -05:00
parent 83243ba32f
commit 4b04fc65ad
19 changed files with 150 additions and 76 deletions

54
src/scene/scenemanager.c Normal file
View File

@@ -0,0 +1,54 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "scenemanager.h"
#include "util/memory.h"
#include "assert/assert.h"
scenemanager_t SCENE_MANAGER;
errorret_t sceneManagerInit(void) {
memoryZero(&SCENE_MANAGER, sizeof(scenemanager_t));
errorOk();
}
void sceneManagerSetScene(scene_t *scene) {
if(SCENE_MANAGER.current) {
SCENE_MANAGER.current->sleep();
SCENE_MANAGER.current->flags &= ~SCENE_FLAG_ACTIVE;
}
SCENE_MANAGER.current = scene;
if(SCENE_MANAGER.current) {
SCENE_MANAGER.current->active();
SCENE_MANAGER.current->flags |= SCENE_FLAG_ACTIVE;
}
}
void sceneManagerUpdate(void) {
if(!SCENE_MANAGER.current) return;
assertTrue(
SCENE_MANAGER.current->flags & SCENE_FLAG_ACTIVE,
"Current scene not active"
);
SCENE_MANAGER.current->update();
}
void sceneManagerRender(void) {
if(!SCENE_MANAGER.current) return;
assertTrue(
SCENE_MANAGER.current->flags & SCENE_FLAG_ACTIVE,
"Current scene not active"
);
SCENE_MANAGER.current->render();
}
void sceneManagerDispose(void) {
assertNull(SCENE_MANAGER.current, "Current scene not null");
}