Refactoring structs Part 1

This commit is contained in:
2021-05-20 22:20:52 -07:00
parent c19f7c1083
commit 5ae1f1c0d4
56 changed files with 484 additions and 422 deletions

30
src/engine/engine.c Normal file
View File

@ -0,0 +1,30 @@
/**
* 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, game_t *game) {
epochInit(&engine->time);
renderInit();
inputInit(&engine->input);
}
void engineUpdateStart(engine_t *engine, game_t *game, float delta) {
epochUpdate(&engine->time, delta);
inputUpdate(&engine->input);
renderFrameStart();
}
bool engineUpdateEnd(engine_t *engine, game_t *game) {
if(inputIsPressed(INPUT_NULL)) return false;
return true;
}
void engineDispose(engine_t *engine, game_t *game) {
inputDispose(&engine->input);
renderDispose();
}

46
src/engine/engine.h Normal file
View File

@ -0,0 +1,46 @@
/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include <dawn/dawn.h>
#include "../input/input.h"
#include "../epoch/epoch.h"
#include "../display/render.h"
/**
* Initializes the provided engine. This will initialize all of the various
* managers for the game to use.
*
* @param engine Engine to initialize.
* @param game Game that intiialized this engine.
*/
void engineInit(engine_t *engine, game_t *game);// TODO: This needs to return valid state.
/**
* Updates the given engine at the start of a frame.
*
* @param engine Engine that is being updated
* @param game Game that initialized the engine update
* @param delta Delta tick provided by the game's platform.
*/
void engineUpdateStart(engine_t *engine, game_t *game, float delta);
/**
* Updates the given engine at the end of a frame.
*
* @param engine Engine to update.
* @param game Game that called this update.
*/
bool engineUpdateEnd(engine_t *engine, game_t *game);
/**
* Cleanup the engine context.
*
* @param engine Engine to clean up.
* @param game Game that initialized the cleanup.
*/
void engineDispose(engine_t *engine, game_t *game);