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