2020-01-23 19:54:19 +01:00
|
|
|
#include <tuyau.h>
|
2020-01-24 12:08:40 +01:00
|
|
|
#include <mario.h>
|
|
|
|
#include <keyboard.h>
|
2020-01-25 20:35:34 +01:00
|
|
|
#include <world.h>
|
2020-01-25 21:23:21 +01:00
|
|
|
#include <framerate.h>
|
2020-01-29 14:34:47 +01:00
|
|
|
#include <camera.h>
|
2020-01-23 19:54:19 +01:00
|
|
|
#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);
|
|
|
|
}
|
|
|
|
}
|
2020-01-24 12:08:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void teleport_active()
|
|
|
|
{
|
|
|
|
for (int i=0; i<nombre_teleporteurs; i++)
|
|
|
|
{
|
|
|
|
teleport_t const t = teleporteurs[i];
|
2020-01-27 16:25:19 +01:00
|
|
|
if ((t.x==mario.p.x/8) && (t.y*8==mario.p.y || t.y*8==mario.p.y+mario.p.h))
|
2020-01-24 12:08:40 +01:00
|
|
|
{
|
|
|
|
if (t.key>=0)
|
|
|
|
{
|
2020-01-29 18:24:33 +01:00
|
|
|
if (!mkb_getstate(t.key))
|
2020-01-24 12:08:40 +01:00
|
|
|
continue;
|
|
|
|
}
|
2020-01-25 21:23:21 +01:00
|
|
|
|
|
|
|
// Animation section
|
2020-01-29 14:34:47 +01:00
|
|
|
if (t.key==MK_DOWN)
|
2020-01-25 21:23:21 +01:00
|
|
|
{
|
|
|
|
while (mario.p.y+mario.p.h>=8*t.y)
|
|
|
|
{
|
2020-01-27 16:46:37 +01:00
|
|
|
dclear(C_WHITE);
|
|
|
|
world_draw(0,0);
|
|
|
|
dupdate();
|
2020-01-25 21:23:21 +01:00
|
|
|
wait_next_frame(); // 10 fps
|
|
|
|
wait_next_frame();
|
2020-01-27 16:46:37 +01:00
|
|
|
mario.p.y--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (t.key==MK_RIGHT)
|
|
|
|
{
|
|
|
|
while (mario.p.x-mario.p.w<=8*t.x)
|
|
|
|
{
|
2020-01-25 21:23:21 +01:00
|
|
|
dclear(C_WHITE);
|
|
|
|
world_draw(0,0);
|
|
|
|
dupdate();
|
2020-01-27 16:46:37 +01:00
|
|
|
wait_next_frame(); // 10 fps
|
|
|
|
wait_next_frame();
|
|
|
|
mario.p.x++;
|
2020-01-25 21:23:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-27 16:53:53 +01:00
|
|
|
mario.p.x=t.tx*8+4; mario.p.y=t.ty*8;
|
2020-01-25 11:54:39 +01:00
|
|
|
mario.p.vx=0; mario.p.vy=0;
|
2020-01-29 14:34:47 +01:00
|
|
|
camera_adjust();
|
2020-01-24 12:08:40 +01:00
|
|
|
}
|
|
|
|
}
|
2020-01-23 19:54:19 +01:00
|
|
|
}
|