diff --git a/SuperCbr.g1a b/SuperCbr.g1a index fcab2be..014e159 100644 Binary files a/SuperCbr.g1a and b/SuperCbr.g1a differ diff --git a/assets-fx/img/spikes.png b/assets-fx/img/spikes.png new file mode 100644 index 0000000..0af4945 Binary files /dev/null and b/assets-fx/img/spikes.png differ diff --git a/include/ennemi.h b/include/ennemi.h index 9a1a6ba..40c21ec 100644 --- a/include/ennemi.h +++ b/include/ennemi.h @@ -43,7 +43,8 @@ typedef struct void ennemiDisplay(ennemi_t const * e); extern ennemi_t * ennemis_global; -extern int ennemis_global_size; +int ennemiesNumber(); + void ennemiesDisplay(); void ennemiMove(ennemi_t * e); diff --git a/include/tile.h b/include/tile.h index 43f7525..af1fc5b 100755 --- a/include/tile.h +++ b/include/tile.h @@ -25,7 +25,7 @@ extern const tileset_t buisson; extern const tileset_t colline; extern const tileset_t castle; extern const tileset_t end_level; - +extern const tileset_t spikes; extern const tileset_t champi; extern const tileset_t fleur; extern const tileset_t life_1up; diff --git a/include/world.h b/include/world.h index 7684a10..9ba66de 100755 --- a/include/world.h +++ b/include/world.h @@ -19,6 +19,7 @@ typedef enum ARBRE, GIFT, COIN, + SPIKES, NUAGE, BUISSON, COLLINE, diff --git a/src/box.c b/src/box.c index 8ebf7a8..bd10ad5 100755 --- a/src/box.c +++ b/src/box.c @@ -7,7 +7,7 @@ int check_collision(box_t *b) { - for (int i=0; i=cameraX()+127) bullets[i].type=0; // delete a bullet if it is out of the screen // contact with ennemies - for (int a=0; a +/** properties **/ const int ennemi_widths [NOMBRE_ENNEMIS] = {0, 8, 8, 8, 8 , 8, 8}; -//const int ennemi_heights[NOMBRE_ENNEMIS] = {0, 8, 12, 9, 12, 9, 8}; const int ennemi_heights[NOMBRE_ENNEMIS] = {0, 8, 8, 8, 8, 8, 8}; +/** ram storage **/ +ennemi_t * ennemis_global=0; +static int ennemis_global_size=0; +int ennemiesNumber() { return ennemis_global_size; } + +void ennemiesInit(ennemi_t * table, int s) +{ + if (ennemis_global) freeProf(ennemis_global); + + ennemis_global_size = ennemis_global = 0; // reset + + if (s==0) return; + int const size = sizeof(ennemi_t) * s; + if ((ennemis_global = mallocProf(size)) == 0) mallocError(); + + ennemis_global_size = s; + memcpy(ennemis_global, table, size); +} + + void ennemiDisplay(ennemi_t const * e) { - if (e->type==NONE) return; - if (e->b.x<=cameraX(0)-e->b.w || e->b.x>=cameraX(0)+127) return; // do not draw if out of the screen + if (e->type == NONE) return; + if (e->b.x <= cameraX(0) - e->b.w || e->b.x >= cameraX(0) + 127) return; // do not draw if out of the screen {// draw int tx=0, ty=0, dsx=0, dsy=0; - tileset_t t={0,ennemi_widths[e->type], ennemi_heights[e->type],1}; + tileset_t t={0, ennemi_widths[e->type], ennemi_heights[e->type], 1}; switch (e->type) { case GOOMBA_ID: @@ -86,16 +106,15 @@ void plante_tour(ennemi_t *e) { e->p1++; e->p1%=PLANTE_NLAPS; - if (0<=e->p1 && e->p1<35) // (plante en bas, en attente) - { - if (abs(mario.p.x-e->b.x)<15) e->p1=0; - } + // En attente + if (0<=e->p1 && e->p1<35) if (abs(mario.p.x-e->b.x)<15) e->p1=0; + if (35<=e->p1 && e->p1<58) { if ((e->p1+1)%3==0) e->b.y++; } - if (58<=e->p1 && e->p1<75){} // plante en attente en haut - if (75<=e->p1 && e->p1<98) + if (58 <= e->p1 && e->p1 < 75){} // plante en attente en haut + if (75 <= e->p1 && e->p1 < 98) { if (e->p1%3==0) e->b.y--; } @@ -332,24 +351,9 @@ void ennemiMove(ennemi_t *e) } } -// Global variables for ennemies -ennemi_t * ennemis_global=0; -int ennemis_global_size=0; + void ennemiesDisplay() { for (int i=0; i #include -#include - #include #include #include @@ -65,6 +63,10 @@ void cellDraw(int cx, int cy, int sx, int sy, int plan) tileDraw(sx, sy, &bloc, 0, 0); break; + case SPIKES: + tileDraw(sx, sy, &spikes, 0, 0); + break; + case BRICK: if (((brick_t*)cell)->time_hit_id) // calculate collision animation { @@ -177,7 +179,7 @@ void worldDraw() void worldMove() { MKB_update(); - for (int i=0; i