supercasiobros/src/tuyau.c

62 lines
1.1 KiB
C

#include <tuyau.h>
#include <mario.h>
#include <keyboard.h>
#include <world.h>
#include <framerate.h>
#include <gint/std/string.h>
static teleport_t teleporteurs[6]={0}; // 6 max
static int nombre_teleporteurs=0; // Nombre d'entités utilisés dans le niveau actuel
void set_teleporteurs(teleport_t const * const t, int const n)
{
nombre_teleporteurs=0;
if (t)
{
if (n>6)
nombre_teleporteurs=6;
else
nombre_teleporteurs=n;
if (nombre_teleporteurs)
{
memcpy(teleporteurs, t, sizeof(teleport_t)*n);
}
}
}
void teleport_active()
{
for (int i=0; i<nombre_teleporteurs; i++)
{
teleport_t const t = teleporteurs[i];
if ((t.x==mario.p.x/8) && (t.y*8==mario.p.y || t.y*8==mario.p.y+mario.p.h))
{
if (t.key>=0)
{
if (!keys[t.key])
continue;
}
// Animation section
if (t.key==MK_LITTLE)
{
while (mario.p.y+mario.p.h>=8*t.y)
{
wait_next_frame(); // 10 fps
wait_next_frame();
dclear(C_WHITE);
world_draw(0,0);
dupdate();
mario.p.y--;
}
}
mario.p.x=t.tx*8; mario.p.y=t.ty*8;
mario.p.vx=0; mario.p.vy=0;
reset_camera();
}
}
}