Added more debug messages and moved the time update function into main.
This commit is contained in:
parent
2e1eaf4c1c
commit
e11f9bea73
|
|
@ -139,11 +139,15 @@ inline void destroy_entity(entity_t *entity)
|
|||
inline void entity_manager_init(entity_manager_t *entity_manager)
|
||||
{
|
||||
linked_list_init(&entity_manager->entities, sizeof(entity_t), (deleter_t)destroy_entity);
|
||||
|
||||
debug_printf("Initialized entity manager.");
|
||||
}
|
||||
|
||||
inline void entity_manager_add_entity(entity_manager_t *entity_manager, entity_t *entity)
|
||||
{
|
||||
linked_list_push_back(&entity_manager->entities, entity);
|
||||
|
||||
debug_printf("Added entity %d to entity manager.", entity->id);
|
||||
}
|
||||
|
||||
// Only for this file
|
||||
|
|
@ -186,4 +190,6 @@ inline void entity_manager_remove_entity(entity_manager_t *entity_manager, unsig
|
|||
inline void entity_manager_exit(entity_manager_t *entity_manager)
|
||||
{
|
||||
linked_list_clear(&entity_manager->entities);
|
||||
|
||||
debug_printf("Exited entity manager.");
|
||||
}
|
||||
|
|
|
|||
11
src/main.c
11
src/main.c
|
|
@ -1,7 +1,17 @@
|
|||
#include "game.h"
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
game_t game;
|
||||
|
||||
static inline void update_time(void)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int exit_status = EXIT_SUCCESS;
|
||||
|
|
@ -10,6 +20,7 @@ int main(void)
|
|||
|
||||
while(game.is_running)
|
||||
{
|
||||
update_time();
|
||||
game_handle_event();
|
||||
game_update();
|
||||
if(game_render()) exit_status = EXIT_FAILURE;
|
||||
|
|
|
|||
Loading…
Reference in New Issue