diff --git a/SuperCbr.g1a b/SuperCbr.g1a index 180a072..319149b 100644 Binary files a/SuperCbr.g1a and b/SuperCbr.g1a differ diff --git a/assets-fx/bin/lvl_1_2.png b/assets-fx/bin/lvl_1_2.png index b449811..0a1f42a 100644 Binary files a/assets-fx/bin/lvl_1_2.png and b/assets-fx/bin/lvl_1_2.png differ diff --git a/include/ennemi.h b/include/ennemi.h index 0c8102d..6799c47 100644 --- a/include/ennemi.h +++ b/include/ennemi.h @@ -24,7 +24,7 @@ extern const int ennemi_heights[NOMBRE_ENNEMIS]; #define KOOPA_R(x,y,dir) {KOOPA_R_ID,{x,y,ennemi_widths[KOOPA_R_ID],ennemi_heights[KOOPA_R_ID],dir,0,0,1},ALIVE,0,dir} #define PLANTE(x,y) {PLANTE_ID,{x,y,ennemi_widths[PLANTE_ID],ennemi_heights[PLANTE_ID],0,0,0,0},ALIVE,0,0} - +// pour plante ID, ymin est associé à p1=0 // Dimensions pr les boites diff --git a/levelconverter/1_2.png b/levelconverter/1_2.png index 5c7a37c..1e2e3e6 100644 Binary files a/levelconverter/1_2.png and b/levelconverter/1_2.png differ diff --git a/levelconverter/levelconv.py b/levelconverter/levelconv.py index cbc7fba..d2ee3ba 100644 --- a/levelconverter/levelconv.py +++ b/levelconverter/levelconv.py @@ -23,7 +23,7 @@ mario_start = (108, 81, 47) nuage = (127, 127, 127) arbre_tronc = (74,35,18) arbre_feuilles = (0,86,0) - +plante = (102,0,127) def color_compare(color1, color2): if color1[0] == color2[0] and color1[1] == color2[1] and color1[2] == color2[2]: @@ -54,19 +54,19 @@ pixels = img.load() for x in range(0,img.size[0]): for i in range(0, img.size[1]): y=img.size[1]-i-1 - + if color_compare(pixels[x,y],empty): code += write_char(0) elif color_compare(pixels[x,y], pierre): code += write_char(1) - + elif color_compare(pixels[x,y], piece): code += write_char(2) elif color_compare(pixels[x,y], brique): code += write_char(3) - + elif color_compare(pixels[x,y],brique_piece): code += write_char(4) @@ -75,7 +75,7 @@ for x in range(0,img.size[0]): elif color_compare(pixels[x,y],boite_champi): code += write_char(6) - + elif color_compare(pixels[x,y],beton): code += write_char(7) @@ -109,8 +109,12 @@ for x in range(0,img.size[0]): elif color_compare(pixels[x,y], arbre_feuilles): code += write_char(17) + elif color_compare(pixels[x,y], plante): + code += write_char(18) + else: code += write_char(0) + print("Warning: unknown type at", x, y, "with pixel color: ", pixels[x,y]) f = open("../assets-fx/bin/lvl_"+filename, 'wb') diff --git a/src/ennemi.c b/src/ennemi.c index 38ae9aa..d45ae05 100644 --- a/src/ennemi.c +++ b/src/ennemi.c @@ -72,13 +72,35 @@ void ennemiDisplay(ennemi_t const * e) { extern image_t img_plante; t.sheet=&img_plante; - // TODO tx ty tsx,tsy + dsx=-4; } } tileDraw(e->b.x-cameraX(0)+dsx, e->b.y-cameraY(mario.p.y)+dsy, &t, tx, ty); } } +static void plante_tour(ennemi_t *e) +{ + if (e->type==PLANTE_ID) + { + e->p1++; + e->p1%=93; + if (0<=e->p1 && e->p1<35) // (plante en bas, en attente) + { + if (abs(mario.p.x-e->b.x)<15) e->p1=0; + } + if (35<=e->p1 && e->p1<52) + { + if ((e->p1+1)%3==0) e->b.y++; + } + if (52<=e->p1 && e->p1<75){} // plante en attente en haut + if (75<=e->p1 && e->p1<92) + { + if (e->p1%3==0) e->b.y--; + } + } +} + bool ennemi_check_collision(ennemi_t *e) { return (boxContact(&e->b, &mario.p)); } void hurtMario() @@ -92,11 +114,11 @@ void ennemiMove(ennemi_t *e) { if (!(e->b.x<=cameraX(0)-e->b.w || e->b.x>=cameraX(0)+127)) e->discovered=1; // for security, tag as discover all drawed ennemies - if (e->life==0 && e->type!=NONE) + if (e->life==DEAD && e->type!=NONE) // dying animation { if (e->p1==0) { - e->b.vx=-2*sgn(e->b.vx); + e->b.vx=2*sgn(e->b.vx); e->b.vy=5; } e->p1++; @@ -127,7 +149,7 @@ void ennemiMove(ennemi_t *e) return; } - for (int i=0; itype!=NONE) @@ -159,17 +181,17 @@ void ennemiMove(ennemi_t *e) } } } + int previous_case=-5; for (int j=0; jb.h; j++) { if ((e->b.x+j)/8!=previous_case) { previous_case=(e->b.x+j)/8; - gift_t * c=(gift_t*)worldGetCell(e->b.x+j ,e->b.y-1); + gift_t * c=(gift_t *)worldGetCell(e->b.x+j, e->b.y-1); if ((c->type==GIFT || c->type==BRICK) && (c->time_hit_id || c->state) && e->life!=DEAD) { - e->life=DEAD; - e->p1=0; + e->life=e->p1=DEAD; scoreAdd(KILL_ENNEMI); break; } @@ -179,10 +201,10 @@ void ennemiMove(ennemi_t *e) if (e->b.y<0) e->type=NONE; const bool mario_fatal_hit = (mario.p.last_vy<=-2 || mario.p.vy<=-2); - boxMove(&e->b); switch (e->type) // move { case KOOPA_R_ID: + boxMove(&e->b); if (e->b.vx) { // demi tour si au dessus du vide int s=-1; @@ -194,6 +216,7 @@ void ennemiMove(ennemi_t *e) // fall through case GOOMBA_ID: case KOOPA_V_ID: + if (e->type!=KOOPA_R_ID) boxMove(&e->b); if (e->b.vx==0) // demi tour si mur { if (e->p1==0) e->b.vx=e->p1=-1; @@ -203,6 +226,7 @@ void ennemiMove(ennemi_t *e) case CARAPACE_VERTE: case CARAPACE_ROUGE: + boxMove(&e->b); if (e->b.vx==0) { if (e->p1<2) @@ -221,6 +245,9 @@ void ennemiMove(ennemi_t *e) } } break; + + case PLANTE_ID: + plante_tour(e); } if (e_hitMario && mario_fatal_hit) switch (e->type) // mario attacks @@ -252,9 +279,9 @@ void ennemiMove(ennemi_t *e) if (mario.p.x<=e->b.x) e->p1=1; e->b.vx=6*e->p1; - mario.p.vy=4; - mario.p.y=e->b.y+ennemi_heights[CARAPACE_VERTE]; - boxMove(&e->b); + mario.p.vy=4; + mario.p.y=e->b.y+ennemi_heights[CARAPACE_VERTE]; + boxMove(&e->b); } else @@ -310,7 +337,7 @@ void ennemiesDisplay() void ennemiesInit(ennemi_t * table, int s) { if (ennemis_global) - freeProf(ennemis_global); + freeProf(ennemis_global); ennemis_global_size=ennemis_global=0; if (!s) return; int size=sizeof(ennemi_t)*s; diff --git a/src/level.c b/src/level.c index e196b53..556da02 100644 --- a/src/level.c +++ b/src/level.c @@ -34,6 +34,7 @@ #define PACKED_NUAGE 15 #define PACKED_ARBRE_TRONC 16 #define PACKED_ARBRE_FEUILLES 17 +#define PACKED_PLANTE 18 void mallocError() { @@ -85,7 +86,7 @@ static void unpackLevel(packed_level_t * p) int sx=0, sy=p->height; // Mario start coords - ennemi_t ennemis[20]={0}; + ennemi_t ennemis[30]={0}; int nombre_ennemis=0; @@ -318,6 +319,12 @@ static void unpackLevel(packed_level_t * p) ennemis[nombre_ennemis]=e; nombre_ennemis++; } + else if (contents==PACKED_PLANTE) + { + ennemi_t e=PLANTE(8*x+4,8*y/*-8*/); + ennemis[nombre_ennemis]=e; + nombre_ennemis++; + } if (contents==PACKED_MARIO_START) {