supercasiobros/src/teleporteur.c

45 lines
801 B
C

#include "teleporteur.h"
#include "mario.h"
#include "keyboard.h"
#include <stdbool.h>
#include <gint/clock.h>
teleporteur_t *teleporteurs=0;
int nombre_teleporteurs=0;
static void check_teleporteur(teleporteur_t * t)
{
if (t->active==0)
return;
bool x=(mario.p.x<=t->x && mario.p.x+mario.p.w>t->x);
bool y=(mario.p.y<=t->y && mario.p.y+mario.p.h>t->y);
if (x&&y)
{
if (t->key==-1)
{
mario_x_max=0;
mario.p.x=t->target_x;
mario.p.y=t->target_y;
mario.p.vx=0;
mario.p.vy=0;
sleep_ms(3,500);
}
else if (keys[t->key])
{
mario_x_max=0;
mario.p.x=t->target_x;
mario.p.y=t->target_y;
mario.p.vx=0;
mario.p.vy=0;
sleep_ms(3,500);
}
}
}
void teleporteurs_check()
{
for (int i=0; i<nombre_teleporteurs; i++)
check_teleporteur(&teleporteurs[i]);
}