88 lines
1.7 KiB
C
88 lines
1.7 KiB
C
/**
|
|
* 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 "asset/asset.h"
|
|
|
|
#include "ui/textbox.h"
|
|
#include "ui/testmenu.h"
|
|
#include "ui/mainmenu.h"
|
|
|
|
#include "game/state/mainmenu.h"
|
|
#include "game/state/mapchange.h"
|
|
#include "game/state/overworld.h"
|
|
|
|
#include "rpg/conversation/conversation.h"
|
|
#include "asset/assetlanguage.h"
|
|
#include "util/memory.h"
|
|
|
|
game_t GAME;
|
|
|
|
void gameInit() {
|
|
memoryInit();
|
|
memorySet(&GAME, 0, sizeof(game_t));
|
|
|
|
timeInit();
|
|
inputInit();
|
|
displayInit();
|
|
assetInit();
|
|
assetLanguageLoad("en.json");
|
|
|
|
textboxInit();
|
|
testMenuInit();
|
|
mainMenuInit();
|
|
conversationInit();
|
|
|
|
GAME.state = GAME_STATE_INITIAL;
|
|
}
|
|
|
|
gameupdateresult_t gameUpdate(const float_t delta) {
|
|
timeUpdate(delta);
|
|
inputUpdate();
|
|
conversationUpdate();
|
|
|
|
switch(GAME.state) {
|
|
case GAME_STATE_INITIAL:
|
|
GAME.state = GAME_STATE_MAIN_MENU;
|
|
break;
|
|
|
|
case GAME_STATE_OVERWORLD:
|
|
gameStateOverworldUpdate();
|
|
break;
|
|
|
|
case GAME_STATE_PAUSED:
|
|
if(inputWasPressed(INPUT_BIND_PAUSE)) GAME.state = GAME_STATE_OVERWORLD;
|
|
break;
|
|
|
|
case GAME_STATE_MAP_CHANGE:
|
|
gameStateMapChangeUpdate();
|
|
break;
|
|
|
|
case GAME_STATE_MAIN_MENU:
|
|
gameStateMainMenuUpdate();
|
|
break;
|
|
|
|
default:
|
|
printf("Updating unknown state %d\n", GAME.state);
|
|
}
|
|
|
|
// Perform render.
|
|
displayUpdate();
|
|
|
|
if(GAME.shouldExit) return GAME_UPDATE_RESULT_EXIT;
|
|
return GAME_UPDATE_RESULT_CONTINUE;
|
|
}
|
|
|
|
void gameDispose() {
|
|
assetDispose();
|
|
displayDispose();
|
|
|
|
memoryTestZero();
|
|
} |