2024-10-09 16:43:10 +02:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <gint/display.h>
|
|
|
|
#include <gint/keyboard.h>
|
|
|
|
|
2024-10-22 12:27:16 +02:00
|
|
|
#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"
|
2024-10-09 16:43:10 +02:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-10-22 12:27:16 +02:00
|
|
|
|