/** * Copyright (c) 2024 Dominic Masters * * This software is released under the MIT License. * https://opensource.org/licenses/MIT */ #include "game/game.h" #include "game/time.h" #include "input.h" #include "display/display.h" #include "ui/textbox.h" #include "asset/asset.h" #include "asset/assetmap.h" game_t GAME; void gameInit() { memset(&GAME, 0, sizeof(game_t)); timeInit(); inputInit(); displayInit(); assetInit(); textboxInit(); GAME.mapNext = MAP_LIST_TEST; GAME.state = GAME_STATE_MAP_CHANGE; } gameupdateresult_t gameUpdate(const float_t delta) { timeUpdate(delta); inputUpdate(); switch(GAME.state) { case GAME_STATE_INITIAL: GAME.state = GAME_STATE_OVERWORLD; break; case GAME_STATE_OVERWORLD: textboxUpdate(); if(GAME.currentMap) mapUpdate(GAME.currentMap); if(inputWasPressed(INPUT_BIND_PAUSE)) GAME.state = GAME_STATE_PAUSED; break; case GAME_STATE_PAUSED: if(inputWasPressed(INPUT_BIND_PAUSE)) GAME.state = GAME_STATE_OVERWORLD; break; case GAME_STATE_MAP_CHANGE: assetMapLoad(MAP_LIST_PATHS[GAME.mapNext], &MAP_MAIN); GAME.state = GAME_STATE_OVERWORLD; GAME.currentMap = &MAP_MAIN; map_t *test = &MAP_MAIN; break; } // Perform render. displayUpdate(); if(GAME.shouldExit) return GAME_UPDATE_RESULT_EXIT; return GAME_UPDATE_RESULT_CONTINUE; } void gameDispose() { assetDispose(); displayDispose(); }