2019-11-21 19:30:54 +01:00
|
|
|
#include "mario.h"
|
|
|
|
#include "tile.h"
|
|
|
|
#include "world.h"
|
|
|
|
#include <gint/display.h>
|
|
|
|
#include <gint/keyboard.h>
|
|
|
|
#include "keyboard.h"
|
|
|
|
#include "box.h"
|
|
|
|
|
|
|
|
extern image_t img_mariosmall;
|
|
|
|
int numero_frame=0;
|
|
|
|
tileset_t mario_small={&img_mariosmall, 8,8, 1};
|
|
|
|
|
|
|
|
pnj mario=
|
|
|
|
{
|
|
|
|
{26,17,8,8,0,0,1},
|
|
|
|
M_SMALL,
|
|
|
|
M_RIGHT1, M_WALK,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
void mario_draw()
|
|
|
|
{
|
|
|
|
if (mario.size==M_SMALL)
|
2019-11-21 19:56:37 +01:00
|
|
|
draw_tile(mario.p.x-world_get_real_x0(mario.p.x), mario.p.y-world_get_real_y0(mario.p.y), &mario_small, mario.type1, mario.type2);
|
2019-11-21 19:30:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int test_sol_le_plus_proche(int x, int y)
|
|
|
|
{
|
|
|
|
int distance=0;
|
|
|
|
int t=0;
|
|
|
|
while (t==0)
|
|
|
|
{
|
|
|
|
int type_sol = world_get_ctg(x, y-1);
|
|
|
|
if (type_sol==CTG_SOIL)
|
|
|
|
t=1;
|
|
|
|
if (type_sol==CTG_DEATH)
|
|
|
|
return distance+1;
|
|
|
|
type_sol = world_get_ctg(x+7, y-1);
|
|
|
|
if (type_sol==CTG_SOIL)
|
|
|
|
t=1;
|
|
|
|
if (type_sol==CTG_DEATH)
|
|
|
|
return distance+1;
|
|
|
|
y--;
|
|
|
|
distance++;
|
|
|
|
}
|
|
|
|
return distance;
|
|
|
|
}
|
|
|
|
|
|
|
|
int global_quit=0;
|
|
|
|
void mario_move()
|
|
|
|
{
|
|
|
|
update_keyboard();
|
|
|
|
int jump = keys[MK_JUMP1] || keys[MK_JUMP2];
|
2019-11-21 19:56:37 +01:00
|
|
|
if (jump)
|
2019-11-24 11:14:16 +01:00
|
|
|
box_jump(&mario.p, 7);
|
2019-11-21 19:56:37 +01:00
|
|
|
|
2019-11-21 19:30:54 +01:00
|
|
|
mario.p.vx = keys[MK_RIGHT] - keys[MK_LEFT];
|
|
|
|
|
2019-11-21 19:56:37 +01:00
|
|
|
box_move(&mario.p); // <-> + gravity
|
2019-11-21 19:30:54 +01:00
|
|
|
}
|
|
|
|
|