#include "level.h" #include "world.h" #include "mario.h" #include "score.h" #include "ennemi.h" #include #include #include #include #include void malloc_error() { extern image_t img_ram; timer_stop(0); dimage(0,0,&img_ram); dupdate(); while (1) getkey(); } void init_level(world_t * lvl) { mario.p.vx=0; mario.p.vy=0; if (w_current) { free(w_current); } int size=sizeof(world_t)*w_current_y*w_current_x; w_current=malloc(size); if (w_current==0) malloc_error(); memcpy(w_current, lvl, size); } void init_ennemies(ennemi_t * table) { if (ennemis_global) { free(ennemis_global); } int size=sizeof(ennemi_t)*ennemis_global_size; ennemis_global=malloc(size); if (ennemis_global==0) malloc_error(); memcpy(ennemis_global, table, size); } void set_level(int n) { new_level(); world_t * lvl=0; if (n==0) { world_t level_0[]= { {EARTH,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {EARTH,1,0,0}, {TUYAU, 0, 3, 0}, {TUYAU, 0, 2, 0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {EARTH,1,0,0}, {TUYAU, 1, 3, 0}, {TUYAU, 1, 2, 0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {EARTH,1,1,0}, {EARTH,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {BRICK,0,0,0}, {0,0,0,0}, {COIN,0,0,0}, {EARTH,1,1,0}, {EARTH,1,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {GIFT,0,0,0}, {0,0,0,0}, {COIN,0,0,0}, {EARTH,1,1,0}, {EARTH,1,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {BRICK,0,0,0}, {0,0,0,0}, {COIN,0,0,0}, {EARTH,1,1,0}, {EARTH,2,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {EARTH,2,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {EARTH,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {EARTH,1,0,0}, {TUYAU, 0, 3, 0}, {TUYAU, 0, 2, 0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {EARTH,1,0,0}, {TUYAU, 1, 3, 0}, {TUYAU, 1, 2, 0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {EARTH,1,0,0}, {TUYAU, 0, 3, 0}, {TUYAU, 0, 2, 0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {EARTH,1,0,0}, {TUYAU, 1, 3, 0}, {TUYAU, 1, 2, 0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {EARTH,1,1,0}, {EARTH,1,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {BRICK,0,0,0}, {0,0,0,0}, {COIN,0,0,0}, {EARTH,1,1,0}, {EARTH,1,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {BRICK,0,0,0}, {0,0,0,0}, {COIN,0,0,0}, {EARTH,1,1,0}, {EARTH,1,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {BRICK,0,0,0}, {0,0,0,0}, {COIN,0,0,0}, {EARTH,1,1,0}, {EARTH,2,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {EARTH,2,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {EARTH,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {EARTH,0,1,0}, {EARTH,0,1,0}, {EARTH,0,1,0}, {EARTH,0,1,0}, {EARTH,0,1,0}, {EARTH,0,1,0}, {EARTH,0,1,0}, {EARTH,0,1,0}, }; lvl=&level_0; extern image_t img_lvl0; w_fond=&img_lvl0; w_current_x=25; w_current_y=8; mario_x_max=0; mario.p.x=25; mario.p.y=16; init_level(lvl); ennemis_global_size=1; ennemi_t ennemies0={GOOMBA,{35,16,8,8,0,0,1},0,0,1}; init_ennemies(&ennemies0); } } void get_lvl_id(int n, char * str) { str[3]='\0'; switch (n) { case 0: str[0]='1'; str[1]='-'; str[2]='1'; return; case 1: str[0]='1'; str[1]='-'; str[2]='2'; return; } }