Time dr freeman?
This commit is contained in:
@@ -10,8 +10,8 @@ set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
|
||||
|
||||
if(NOT DEFINED DUSK_TARGET_SYSTEM)
|
||||
#set(DUSK_TARGET_SYSTEM "psp")
|
||||
set(DUSK_TARGET_SYSTEM "linux")
|
||||
# set(DUSK_TARGET_SYSTEM "psp")
|
||||
endif()
|
||||
|
||||
# Prep cache
|
||||
|
@@ -33,14 +33,22 @@ void gameInit(void) {
|
||||
|
||||
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 >= DUSK_TIME_STEP) {
|
||||
sceneUpdate();
|
||||
uiTextboxUpdate();
|
||||
eventUpdate();
|
||||
|
||||
consoleUpdate();
|
||||
inputUpdate();
|
||||
|
||||
timeSinceLastTick -= DUSK_TIME_STEP;
|
||||
TIME.lastTick = TIME.time;
|
||||
}
|
||||
|
||||
if(inputPressed(INPUT_BIND_QUIT)) consoleExec("quit");
|
||||
consoleUpdate();
|
||||
}
|
||||
|
||||
void gameDispose(void) {
|
||||
|
@@ -16,10 +16,10 @@ void timeInit(void) {
|
||||
}
|
||||
|
||||
void timeUpdate(void) {
|
||||
#if DUSK_DYNAMIC_TIME
|
||||
#if DUSK_TIME_DYNAMIC
|
||||
TIME.delta = timeDeltaGet();
|
||||
#else
|
||||
TIME.delta = DUSK_TIME_STEP;
|
||||
TIME.delta = DUSK_TIME_PLATFORM_STEP;
|
||||
#endif
|
||||
|
||||
TIME.time += TIME.delta;
|
||||
|
@@ -10,18 +10,21 @@
|
||||
|
||||
typedef struct {
|
||||
float_t delta;
|
||||
float_t lastTick;
|
||||
float_t time;
|
||||
} dusktime_t;
|
||||
|
||||
extern dusktime_t TIME;
|
||||
|
||||
#ifndef DUSK_DYNAMIC_TIME
|
||||
#define DUSK_DYNAMIC_TIME 1
|
||||
#define DUSK_TIME_STEP (1.0f / 60.0f) // Default to 60FPS
|
||||
|
||||
#ifndef DUSK_TIME_DYNAMIC
|
||||
#define DUSK_TIME_DYNAMIC 1
|
||||
#endif
|
||||
|
||||
#if DUSK_DYNAMIC_TIME == 0
|
||||
#ifndef DUSK_TIME_STEP
|
||||
#define DUSK_TIME_STEP (1.0f / 60.0f)
|
||||
#if DUSK_TIME_DYNAMIC == 0
|
||||
#ifndef DUSK_TIME_PLATFORM_STEP
|
||||
#define DUSK_TIME_PLATFORM_STEP DUSK_TIME_STEP
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -35,7 +38,7 @@ void timeInit(void);
|
||||
*/
|
||||
void timeUpdate(void);
|
||||
|
||||
#if DUSK_DYNAMIC_TIME == 1
|
||||
#if DUSK_TIME_DYNAMIC == 1
|
||||
/**
|
||||
* Gets the time delta since the last frame, in seconds. Tied to the
|
||||
* platform.
|
||||
|
@@ -20,7 +20,7 @@ target_compile_definitions(${DUSK_TARGET_NAME}
|
||||
RENDER_HEIGHT=272
|
||||
RENDER_WINDOW_WIDTH_DEFAULT=480
|
||||
RENDER_WINDOW_HEIGHT_DEFAULT=272
|
||||
DUSK_DYNAMIC_TIME=0
|
||||
DUSK_TIME_DYNAMIC=0
|
||||
)
|
||||
|
||||
# Includes
|
||||
|
@@ -8,7 +8,7 @@
|
||||
#include "time.h"
|
||||
#include "dusksdl2.h"
|
||||
|
||||
#if DUSK_DYNAMIC_TIME
|
||||
#if DUSK_TIME_DYNAMIC
|
||||
uint32_t TIME_LAST = 0;
|
||||
|
||||
float_t timeDeltaGet(void) {
|
||||
|
Reference in New Issue
Block a user