Ajout d'une boucle de logique
This commit is contained in:
parent
e93cec3894
commit
534ffbe6f2
Binary file not shown.
|
@ -16,6 +16,10 @@
|
|||
|
||||
#define player_height 0x7FFF
|
||||
|
||||
#define TPS 20
|
||||
|
||||
#define tick_time (int)((1.0/(float)TPS) * 1000.0)
|
||||
|
||||
//param. graphiques
|
||||
|
||||
//int, qui règle l'upscale de la fenêtre SDL
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
typedef int32_t fixed_t;
|
||||
/* Standard arithmetic. */
|
||||
|
||||
#define fix(x) ((int)((x) * 65536))
|
||||
|
||||
//GCC complained when in inline functions
|
||||
#define ffloor(f) ((int)(f) >> 16)
|
||||
|
||||
|
@ -58,8 +60,6 @@ static inline fixed_t fdiv(fixed_t left, fixed_t right)
|
|||
return d / right;
|
||||
}
|
||||
|
||||
#define fix(x) ((int)((x) * 65536))
|
||||
|
||||
static inline fixed_t fixdouble(double constant)
|
||||
{
|
||||
return (fixed_t)(constant * 65536);
|
||||
|
|
|
@ -112,7 +112,7 @@ int main(){
|
|||
|
||||
keys_get(&game);
|
||||
|
||||
//logic();
|
||||
do_logic(&game);
|
||||
|
||||
if (disp_frame_time == 1) dprint( 1, 1, C_BLACK, "Fps : %d", (int)(1.0/((float)frame_time/1000.0)));
|
||||
|
||||
|
|
21
src/moteur.c
21
src/moteur.c
|
@ -153,12 +153,29 @@ void move(Game *game, uint32_t keys) {
|
|||
/*
|
||||
void draw_background(int back_id){ //a refaire
|
||||
|
||||
}*/
|
||||
|
||||
fixed_t ticks_todo;
|
||||
|
||||
void do_logic(Game *game){
|
||||
extern int frame_time;
|
||||
extern fixed_t ticks_todo;
|
||||
|
||||
ticks_todo += fix(frame_time);
|
||||
fixed_t old = ticks_todo;
|
||||
int ticks_now = ffloor(ticks_todo/tick_time);
|
||||
ticks_todo = old % tick_time;
|
||||
|
||||
for(int t_done = 0; t_done < ticks_todo; t_done++){
|
||||
logic(game);
|
||||
}
|
||||
}
|
||||
|
||||
void logic(){
|
||||
//logique (logique)
|
||||
void logic(Game *game){
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
void draw_f(image_t *vram){ //a refaire
|
||||
|
||||
}*/
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#define moteur_h
|
||||
|
||||
void draw_background(int back_id);
|
||||
void logic();
|
||||
void do_logic(Game *game);
|
||||
void draw_f(image_t *vram);
|
||||
void draw_walls(Game *game, image_t *vram);
|
||||
void move(Game *game, uint32_t keys);
|
||||
|
|
Loading…
Reference in New Issue