diff options
Diffstat (limited to 'src/scenes/sceneManager.c')
| -rw-r--r-- | src/scenes/sceneManager.c | 47 |
1 files changed, 39 insertions, 8 deletions
diff --git a/src/scenes/sceneManager.c b/src/scenes/sceneManager.c index 4d42ed9..bb70864 100644 --- a/src/scenes/sceneManager.c +++ b/src/scenes/sceneManager.c @@ -1,14 +1,45 @@ #include "scenes.h" +#include <stdlib.h> +#include <sys/types.h> -void UpdateScene(enum SCENE scene) { - switch (scene) { - case MAIN_MENU: MainMenuUpdate(); - } +Scene **sceneStack = NULL; +uint sceneStackDepth = 0; + +Scene *getCurrentScene() { + if (sceneStackDepth == 0) return false; + return sceneStack[sceneStackDepth - 1]; +} + +bool InitSceneStack() { + sceneStack = malloc(sizeof(Scene) * SCENE_STACK_SIZE); + return sceneStack != NULL; +} + +bool AddScene(Scene *newScene) { + if (newScene == NULL || sceneStackDepth == SCENE_STACK_SIZE) + return false; + + sceneStack[sceneStackDepth] = newScene; + sceneStackDepth += 1; + + return true; } -void DrawScene(enum SCENE scene) { - switch (scene) { - case MAIN_MENU: MainMenuDraw(); - } +void DeleteSceneFromStack() { + Scene *currentScene = getCurrentScene(); + if (currentScene == NULL) return; + currentScene->Deint(currentScene); + sceneStack[--sceneStackDepth] = NULL; } +bool DrawScene() { + Scene *currentScene = getCurrentScene(); + if (currentScene == NULL) return false; + return currentScene->Draw(currentScene); +} + +bool UpdateScene() { + Scene *currentScene = getCurrentScene(); + if (currentScene == NULL) return false; + return currentScene->Update(currentScene); +} |
