#include #include #include #include #include #include "fixed.h" #include "map.h" #include "game.h" #include "utils.h" #include "moteur.h" #include "sprites.h" int lhook_c = 0; RcLogicFunc *logic_hooks[HINDEX_S]; int add_logic_hook(RcLogicFunc *func){ if(lhook_c >= HINDEX_S) return 1; logic_hooks[lhook_c++] = func; return 0; } //TODO int remove_logic_hook(RcLogicFunc *func){ } void clear_logic_hooks(){ lhook_c = 0; } //Time per tick, in µs #define LOGIC_TIME (int)((1.0/TPS) * 1000000) void do_logic(RcGame *game, int delta){ game->logic_time += delta; for(; game->logic_time > LOGIC_TIME; game->logic_time -= LOGIC_TIME){ for(int i = 0; i < lhook_c; i++){ //TODO : Be less dramatic if(logic_hooks[i](game)){ game->flags.exit = 1; return; } } } }