49 lines
1.1 KiB
C
49 lines
1.1 KiB
C
/**
|
|
* Copyright (c) 2021 Dominic Masters
|
|
*
|
|
* This software is released under the MIT License.
|
|
* https://opensource.org/licenses/MIT
|
|
*/
|
|
|
|
#include "engine.h"
|
|
|
|
void engineInit(engine_t *engine) {
|
|
randSeed(123);
|
|
|
|
#if defined(GAME_NAME)
|
|
engine->name = GAME_NAME;
|
|
#else
|
|
engine->name = "Dawn";
|
|
#endif
|
|
|
|
clientInit(&engine->client);
|
|
epochInit(&engine->time);
|
|
saveManagerInit(&engine->save);
|
|
inputInit(&engine->input);
|
|
assetManagerInit(&engine->assetManager, &engine->save);
|
|
renderInit();
|
|
|
|
assetManagerStart(&engine->assetManager);
|
|
}
|
|
|
|
void engineUpdateStart(engine_t *engine, float delta) {
|
|
epochUpdate(&engine->time, delta);
|
|
inputUpdate(&engine->input);
|
|
assetManagerUpdate(&engine->assetManager);
|
|
|
|
renderFrameStart(&engine->render);
|
|
}
|
|
|
|
bool engineUpdateEnd(engine_t *engine) {
|
|
if(inputIsPressed(&engine->input, INPUT_NULL)) {
|
|
printf("Game exit requested\n");
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
void engineDispose(engine_t *engine) {
|
|
assetManagerDispose(&engine->assetManager);
|
|
inputDispose(&engine->input);
|
|
renderDispose();
|
|
} |