#include "mario.h" #include "tile.h" #include "world.h" #include #include #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 }; int mario_x_max=0; int mario_time_accel=0; int mario_dead=0; void mario_draw() { if (mario.size==M_SMALL) 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); } 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; } static int sgn(int x) { if (x>0) return 1; else if (x<0) return -1; else return 0; } int global_quit=0; void mario_move() { update_keyboard(); int jump = keys[MK_JUMP1] || keys[MK_JUMP2]; if (jump) box_jump(&mario.p, 7); int vx=keys[MK_RIGHT] - keys[MK_LEFT]; if (vx) { if (sgn(vx)==sgn(mario.p.vx) || vx==0) mario_time_accel++; mario_time_accel%=4; if (mario_time_accel==0) { if (keys[MK_RUN]) { if(mario.p.vx*sgn(mario.p.vx)<=4) mario.p.vx+=vx; } else { if(mario.p.vx*sgn(mario.p.vx)<=2) mario.p.vx+=vx; } } if (mario.p.x+mario.p.vx + gravity if (mario.p.x>mario_x_max) mario_x_max=mario.p.x; if (mario.p.y<0) mario_dead=1; }