#include "level.h" #include "world.h" #include "mario.h" #include "score.h" #include "ennemi.h" #include "keyboard.h" #include #include #include #include #include #include #include #include #include #define PACKED_EMPTY 0 #define PACKED_STONE 1 #define PACKED_COIN 2 #define PACKED_BRICK 3 #define PACKED_BRICK_COIN 4 #define PACKED_BOX_COIN 5 #define PACKED_BOX_CHAMPI 6 #define PACKED_BETON 7 #define PACKED_TUYAU_BOUT 8 #define PACKED_TUYAU_MIDDLE 9 #define PACKED_FLAG 10 #define PACKED_GOOMBA 11 #define PACKED_KOOPA_VERT 12 #define PACKED_KOOPA_ROUGE 13 #define PACKED_MARIO_START 14 #define PACKED_NUAGE 15 void malloc_error() { extern image_t img_ram; timer_stop(0); dimage(0,0,&img_ram); dupdate(); while (1) mkb_getkey(); } static uint8_t pack_access(packed_level_t const * const p, unsigned int x, unsigned int y) { if (xwidth && yheight) { ll_sendp(LEVEL_INFO, "\n[i]pack access at %d,%d",x,y); return p->data[x*p->height+y]; } else { ll_sendp(LEVEL_WARNING, "\n[w]pack access out of range at %d,%d",x,y); return PACKED_EMPTY; } } static void cell_set(cell_t *const array, unsigned int w, unsigned int h, unsigned int x, unsigned int y, cell_t const cell) { if (xwidth; unsigned int h = p->height; ll_sendp(LEVEL_INFO, "\nUnpacking level %dx%d", w,h); cell_t * c = (cell_t *) malloc(sizeof(cell_t) * w * h); ll_sendp(LEVEL_INFO, "\n[i]malloc %d", sizeof(cell_t) * w * h); if (c==0) { // overriding parameters w = 232;//p->width; h = 13;//p->height; ll_sendp(LEVEL_CRITICAL, "\n[e]malloc failed !\n[i]Trying defaults:\n %dx%d", w,h); ll_sendp(LEVEL_WARNING, "\n[w]writing into pack new coordinates:\n %dx%d", w,h); p->width=w; p->height=h; cell_t * c = (cell_t *) malloc(sizeof(cell_t) * w * h); if (c==0) malloc_error(); } ll_set_level(LEVEL_WARNING); int sx=0, sy=p->height; // Mario start coords ll_sendp(LEVEL_INFO, "\n[i]Converting...", w,h); ennemi_t ennemis[20]={0}; int nombre_ennemis=0; for (unsigned int x=0; x