Compare commits
No commits in common. "dd1aeae9f5d413d56d39f14307c7f2a02505d121" and "ccc40e8d15ebc168fb83c0cff5bc9d12a8a4f270" have entirely different histories.
dd1aeae9f5
...
ccc40e8d15
|
|
@ -3,7 +3,6 @@
|
|||
#include <SDL3/SDL.h>
|
||||
#include <stdlib.h>
|
||||
#include "asset_manager.h"
|
||||
#include "game.h"
|
||||
#include "errors.h"
|
||||
|
||||
SDL_Window *window = NULL;
|
||||
|
|
@ -17,7 +16,7 @@ inline int display_init(void)
|
|||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if(!SDL_SetAppMetadata("2D_Engine", "1.0", "2D_Engine_SDL2_Core"))
|
||||
if(!SDL_SetAppMetadata("2D_Engine", "1.0", "2D_Engine"))
|
||||
{
|
||||
error_printf("Failed to set app metadata : %s", SDL_GetError());
|
||||
return EXIT_FAILURE;
|
||||
|
|
@ -95,36 +94,6 @@ inline int display_clear(void)
|
|||
inline void display_update(void)
|
||||
{
|
||||
SDL_RenderPresent(renderer);
|
||||
|
||||
#if DEBUG >= 1
|
||||
float fps = 1000.0f / game.delta_time_ms;
|
||||
static float max_fps_10s = 0.0f;
|
||||
static float low_fps_10s = 10000000.0f;
|
||||
|
||||
if(fps > max_fps_10s) max_fps_10s = fps;
|
||||
if(fps < low_fps_10s) low_fps_10s = fps;
|
||||
|
||||
static float fps_update_delta_time = 0.0f;
|
||||
fps_update_delta_time += game.delta_time_ms;
|
||||
|
||||
if(fps_update_delta_time >= 100.0f)
|
||||
{
|
||||
fps_update_delta_time = 0.0f;
|
||||
char title[100];
|
||||
sprintf(title, "2D_Engine | cur: %.2ffps | max: %.2ffps | low: %.2ffps", fps, max_fps_10s, low_fps_10s);
|
||||
SDL_SetWindowTitle(window, title);
|
||||
}
|
||||
|
||||
static float fps_max_low_update_delta_time = 0.0f;
|
||||
fps_max_low_update_delta_time += game.delta_time_ms;
|
||||
|
||||
if(fps_max_low_update_delta_time > 10000.0f)
|
||||
{
|
||||
fps_max_low_update_delta_time = 0.0f;
|
||||
max_fps_10s = 0.0f;
|
||||
low_fps_10s = 10000000.0f;
|
||||
}
|
||||
#endif // DEBUG >= 1
|
||||
}
|
||||
|
||||
int display_draw_texture(texture_t *texture, rect_t *src_rect, rect_t *dst_rect, bool flip)
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ component_t *entity_new_component(entity_t *entity, component_type_t component_t
|
|||
|
||||
if(component->component_init(component)) return NULL;
|
||||
|
||||
if(linked_list_push_back(&entity->components, component_elem)) return NULL;
|
||||
if(linked_list_push_front(&entity->components, component_elem)) return NULL;
|
||||
|
||||
return component;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@ game_t game;
|
|||
|
||||
static inline void update_time(void)
|
||||
{
|
||||
static uint64_t last_clock_state = 0;
|
||||
uint64_t start_clock = SDL_GetTicksNS();
|
||||
game.delta_time_ms = SDL_NS_TO_MS((float)(start_clock - last_clock_state));
|
||||
static uint32_t last_clock_state = 0;
|
||||
uint32_t start_clock = SDL_GetTicks();
|
||||
game.delta_time_ms = (float)(start_clock - last_clock_state);
|
||||
last_clock_state = start_clock;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue