Refactoring structs Part 1

This commit is contained in:
2021-05-20 22:20:52 -07:00
parent 17ddb4246a
commit 9bcf6223b6
56 changed files with 484 additions and 422 deletions

26
src/epoch/epoch.c Normal file
View File

@ -0,0 +1,26 @@
/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "epoch.h"
void epochInit(epoch_t *epoch) {
epoch->delta = EPOCH_FIXED_STEP;
epoch->last = EPOCH_FIXED_STEP;
epoch->current = EPOCH_FIXED_STEP + EPOCH_FIXED_STEP;
}
void epochUpdate(epoch_t *epoch, float platformDelta) {
platformDelta = mathMax(
mathMin(platformDelta, EPOCH_FIXED_STEP),
0
);
epoch->last = epoch->current;
epoch->current = epoch->current + platformDelta;
epoch->delta = epoch->current - epoch->last;
epoch->fixedDelta = EPOCH_FIXED_STEP;
}

24
src/epoch/epoch.h Normal file
View File

@ -0,0 +1,24 @@
/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include <dawn/dawn.h>
/**
* Initializes the epoch time tracking.
*
* @param epoch Epoch to initialize.
*/
void epochInit(epoch_t *epoch);
/**
* Ticks the current epoch time.
*
* @param epoch Epoch to update.
* @param platformDelta The delta step between frames from the platform engine.
*/
void epochUpdate(epoch_t *epoch, float platformDelta);