#include #include #include #include #include #include "C3D/fixed.h" #include "C3D/map.h" #include "C3D/game.h" #include "C3D/utils.h" #include "C3D/moteur.h" #include "C3D/sprites.h" #include "C3D/config.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; } } } }