mirror of
https://git.planet-casio.com/Fcalva/Copy3DEngine.git
synced 2024-12-28 20:43:44 +01:00
49 lines
889 B
C
49 lines
889 B
C
|
#include <stdint.h>
|
||
|
#include <stdlib.h>
|
||
|
#include <string.h>
|
||
|
|
||
|
#include <gint/display.h>
|
||
|
#include <gint/keyboard.h>
|
||
|
|
||
|
#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;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|