57 lines
1.1 KiB
C
57 lines
1.1 KiB
C
/**
|
|
* Copyright (c) 2025 Dominic Masters
|
|
*
|
|
* This software is released under the MIT License.
|
|
* https://opensource.org/licenses/MIT
|
|
*/
|
|
|
|
#include "game.h"
|
|
#include "util/memory.h"
|
|
#include "world/chunk.h"
|
|
#include "display/scene.h"
|
|
#include "world/overworld.h"
|
|
#include "input.h"
|
|
#include "event/event.h"
|
|
#include "ui/uitextbox.h"
|
|
#include "console/console.h"
|
|
#include "util/memory.h"
|
|
#include "time.h"
|
|
|
|
game_t GAME;
|
|
|
|
void gameInit(void) {
|
|
memoryZero(&GAME, sizeof(game_t));
|
|
GAME.running = true;
|
|
|
|
timeInit();
|
|
consoleInit();
|
|
inputInit();
|
|
eventInit();
|
|
uiTextboxInit();
|
|
sceneInit();
|
|
}
|
|
|
|
void gameUpdate(void) {
|
|
timeUpdate();
|
|
|
|
// Game logic is tied to 60FPS for now, saves me a lot of hassle with float
|
|
// issues
|
|
float_t timeSinceLastTick = TIME.time - TIME.lastTick;
|
|
while(timeSinceLastTick >= TIME_STEP) {
|
|
|
|
sceneUpdate();
|
|
uiTextboxUpdate();
|
|
eventUpdate();
|
|
inputUpdate();
|
|
|
|
timeSinceLastTick -= TIME_STEP;
|
|
TIME.lastTick = TIME.time;
|
|
}
|
|
|
|
if(inputPressed(INPUT_BIND_QUIT)) consoleExec("quit");
|
|
consoleUpdate();
|
|
}
|
|
|
|
void gameDispose(void) {
|
|
sceneDispose();
|
|
} |