diff --git a/SuperCbr.g1a b/SuperCbr.g1a index ba7378e..633f166 100644 Binary files a/SuperCbr.g1a and b/SuperCbr.g1a differ diff --git a/assets-fx/bin/lvl_1_3.png b/assets-fx/bin/lvl_1_3.png new file mode 100644 index 0000000..13f1297 Binary files /dev/null and b/assets-fx/bin/lvl_1_3.png differ diff --git a/assets-fx/icon-fx.png-autosave.kra b/assets-fx/icon-fx.png-autosave.kra new file mode 100644 index 0000000..460ad89 Binary files /dev/null and b/assets-fx/icon-fx.png-autosave.kra differ diff --git a/assets-fx/icon-fx.png~ b/assets-fx/icon-fx.png~ new file mode 100755 index 0000000..a1a132c Binary files /dev/null and b/assets-fx/icon-fx.png~ differ diff --git a/assets-fx/img/tree.png b/assets-fx/img/arbre.png similarity index 100% rename from assets-fx/img/tree.png rename to assets-fx/img/arbre.png diff --git a/include/plateforme.h b/include/plateforme.h index ae9f7d6..7c89f19 100644 --- a/include/plateforme.h +++ b/include/plateforme.h @@ -5,16 +5,13 @@ #define P_MOVING_H 1 #define P_MOVING_V 2 - +#include typedef struct { unsigned type; int xinit, yinit; - int x, y; - int width; // height fixed to 3 - int v, vinit; union { @@ -27,13 +24,14 @@ typedef struct int ymax; }; int counter; + box_t b; } plateforme_t; #define PLATEFORME_HEIGHT 3 -#define PLATEFORME_FALLING(x,y,w) {P_FALLING,x,y,x,y,w,0,0,.xmin=0,.xmax=0,0} -#define PLATEFORME_MOVING_H(x,y,w,v,x0,x1) {P_MOVING_H,x,y,x,y,w,0,v,.xmin=x0,.xmax=x1,0} -#define PLATEFORME_MOVING_V(x,y,w,v,y0,y1) {P_MOVING_V,x,y,x,y,w,0,v,.ymin=y0,.ymax=y1,0} +#define PLATEFORME_FALLING(x,y,w) {P_FALLING,x,y,.xmin=0,.xmax=0,0, {x,y,w,3, 0,0, 0,0}} +#define PLATEFORME_MOVING_H(x,y,w,v,x0,x1) {P_MOVING_H,x,y,.xmin=x0,.xmax=x1,0, {x,y,w,3, v,0, 0,0}} +#define PLATEFORME_MOVING_V(x,y,w,v,y0,y1) {P_MOVING_V,x,y,.ymin=y0,.ymax=y1,0, {x,y,w,3, 0,v, 0,0}} //void reset_plateforme(plateforme_t* p); diff --git a/include/tile.h b/include/tile.h index b537632..ac1d627 100755 --- a/include/tile.h +++ b/include/tile.h @@ -14,6 +14,7 @@ typedef struct } tileset_t; extern const tileset_t tuyau; +extern const tileset_t arbre; extern const tileset_t brick; extern const tileset_t earth; extern const tileset_t gift; diff --git a/include/world.h b/include/world.h index 22ae31a..9cc186c 100755 --- a/include/world.h +++ b/include/world.h @@ -8,10 +8,23 @@ #define W_SIZE_X 160 #define W_SIZE_Y 16 +typedef enum +{ + EMPTY=0, + EARTH, + BRICK, + BLOC, + END_LEVEL, + TUYAU, + ARBRE, + GIFT, + COIN, + NUAGE, + BUISSON, + COLLINE, + CASTLE, +} cell_id; -#define EMPTY 0 - -#define EARTH 1 // X, Y, _ (XY tileset) typedef struct { unsigned type :8; @@ -20,7 +33,6 @@ typedef struct unsigned y :4; } earth_t; -#define BRICK 2 typedef struct { unsigned type :8; @@ -31,14 +43,12 @@ typedef struct unsigned number :4; } brick_t; -#define BLOC 3 typedef struct { unsigned type :8; unsigned data :24; // raw binary format } bloc_t; -#define END_LEVEL 4 typedef struct { unsigned type :8; @@ -50,7 +60,6 @@ typedef struct } end_level_t; -#define TUYAU 5 // X, Y, _ (XY tileset) typedef struct { unsigned type :8; @@ -59,7 +68,15 @@ typedef struct unsigned y :4; } tuyau_t; -#define GIFT 6 // s, t, n (state[hit time], type[vide=0, piece=1, ...], qté) +typedef struct +{ + unsigned type :8; + unsigned empty :16; + unsigned x :4; + unsigned y :4; +} arbre_t; + + typedef struct { unsigned type :8; @@ -70,7 +87,6 @@ typedef struct unsigned number :4; } gift_t; -#define COIN 7 // s, _, _ (state) typedef struct { unsigned type :8; @@ -78,10 +94,6 @@ typedef struct unsigned taken :4; } coin_t; -#define NUAGE 8 // X, Y, _ (XY tileset) -#define BUISSON 9 // X, Y, _ (XY tileset) -#define COLLINE 10 // X, Y, _ (XY tileset) -#define CASTLE 11 typedef struct { unsigned type :8; @@ -90,7 +102,7 @@ typedef struct unsigned y :4; } deco_t; -// Generic container +// Generic container 32 bits typedef struct { unsigned type :8; diff --git a/levelconverter/1-3.png~ b/levelconverter/1-3.png~ new file mode 100644 index 0000000..8e15bd7 Binary files /dev/null and b/levelconverter/1-3.png~ differ diff --git a/levelconverter/1_1.png b/levelconverter/1_1.png index 32a09b1..39cc36c 100644 Binary files a/levelconverter/1_1.png and b/levelconverter/1_1.png differ diff --git a/levelconverter/1_1.png~ b/levelconverter/1_1.png~ new file mode 100644 index 0000000..39cc36c Binary files /dev/null and b/levelconverter/1_1.png~ differ diff --git a/levelconverter/1_3.png b/levelconverter/1_3.png new file mode 100644 index 0000000..aaddb36 Binary files /dev/null and b/levelconverter/1_3.png differ diff --git a/levelconverter/1_3.png~ b/levelconverter/1_3.png~ new file mode 100644 index 0000000..3bd9c9c Binary files /dev/null and b/levelconverter/1_3.png~ differ diff --git a/levelconverter/levelconv.py b/levelconverter/levelconv.py index 929263a..d28972a 100644 --- a/levelconverter/levelconv.py +++ b/levelconverter/levelconv.py @@ -16,14 +16,14 @@ beton = (84, 84, 84) tuyau_milieu = (0, 255, 102) tuyau_bout = (50, 255, 0) drapeau = (0, 255, 216) - goomba = (127, 76, 0) koopa_vert = (25, 127, 0) koopa_rouge = (127, 0, 0) - mario_start = (108, 81, 47) - nuage = (127, 127, 127) +arbre_tronc = (74,35,18) +arbre_feuilles = (0,86,0) + def color_compare(color1, color2): if color1[0] == color2[0] and color1[1] == color2[1] and color1[2] == color2[2]: @@ -103,6 +103,12 @@ for x in range(0,img.size[0]): elif color_compare(pixels[x,y], nuage): code += write_char(15) + elif color_compare(pixels[x,y], arbre_tronc): + code += write_char(16) + + elif color_compare(pixels[x,y], arbre_feuilles): + code += write_char(17) + else: code += write_char(0) diff --git a/src/box.c b/src/box.c index 9b5496e..58b3e70 100755 --- a/src/box.c +++ b/src/box.c @@ -27,18 +27,18 @@ static void move_x(box_t * b) { int sgn_vx=sgn(b->vx); - int t_vx=((sgn_vx*b->vx+time_id%2)/2)*sgn_vx; + int t_vx=((sgn_vx*b->vx+time_id%2)/2)*sgn_vx; // si n impair, alterne entre n+1 n-1 sgn_vx=sgn(t_vx); int coef=1;//1; if (world_get_ctg(b->x, b->y)==CTG_WATER || world_get_ctg(b->x+b->w-1, b->y)==CTG_WATER) - coef=2; + coef=2;//ralentir dans l'eau if (frame_id%coef) return; if (sgn_vx) { - for (int i=sgn_vx; i<=sgn_vx*t_vx; i++) + for (int i=1; i<=sgn_vx*t_vx; i++) { for (int j=0; jh; j++) { diff --git a/src/level.c b/src/level.c index c096054..d7357c2 100644 --- a/src/level.c +++ b/src/level.c @@ -14,6 +14,7 @@ #include #include #include +#include #define PACKED_EMPTY 0 #define PACKED_STONE 1 @@ -31,6 +32,8 @@ #define PACKED_KOOPA_ROUGE 13 #define PACKED_MARIO_START 14 #define PACKED_NUAGE 15 +#define PACKED_ARBRE_TRONC 16 +#define PACKED_ARBRE_FEUILLES 17 void malloc_error() { @@ -279,6 +282,26 @@ static void unpack_level(packed_level_t * p) cell_t t={NUAGE,16*px+py}; cell = t; } + else if (contents==PACKED_ARBRE_TRONC) + { + cell_t t={ARBRE,0x11}; + cell = t; + } + else if (contents==PACKED_ARBRE_FEUILLES) + { + int px=0; + if (pack_access(p,x+1,y)==PACKED_ARBRE_FEUILLES) + { + if (pack_access(p,x-1,y)==PACKED_ARBRE_FEUILLES) + px=1; + else + px=0; + } + else + px=2; + cell_t t={ARBRE,16*px}; + cell = t; + } cell_set(c,w,h,x,y,cell); @@ -361,6 +384,12 @@ void set_level(int w, int l) }; init_plateformes(plateforme0,sizeof(plateforme0)/sizeof(plateforme_t)); } + + if (w+1==1 && l+1==3) // 1-2 + { + extern packed_level_t bin_lvl_1_3; + unpack_level(&bin_lvl_1_3); + } } void get_lvl_id(int w, int l, char * str) diff --git a/src/plateforme.c b/src/plateforme.c index d13d617..afa90ac 100644 --- a/src/plateforme.c +++ b/src/plateforme.c @@ -15,72 +15,45 @@ plateforme_t* plateformes=0; void reset_plateforme(plateforme_t* p) { - p->x=p->xinit; - p->y=p->yinit; - p->v=p->vinit; + p->b.x=p->xinit; + p->b.y=p->yinit; } void move_plateforme(plateforme_t* p) -{/* - if (p->x+p->width-world_get_real_x0()<-50) - return; - if (p->x-world_get_real_x0()-128>50) - return; - - - if (p->y-world_get_real_y0()-64>50) - return; - if (p->y+3-world_get_real_y0()<-50) - return; - */ - -int xc = (mario.p.xx+p->width && mario.p.x>=p->x) || (mario.p.x+mario.p.wx+p->width && mario.p.x+mario.p.w>=p->x); -int yc = (mario.p.y-3==p->y); - -if (p->type==P_FALLING) { - if (p->v) - p->v++; - p->y+=p->v/2; -} -if (p->type==P_MOVING_H) -{ - int s=sgn(p->v); - int t_v=((s*p->v+time_id%2)/2)*s; - if (p->v==0) - p->v=p->vinit; - p->x+=t_v; + int xc = (mario.p.xb.x+p->b.w && mario.p.x>=p->b.x) || (mario.p.x+mario.p.wb.x+p->b.w && mario.p.x+mario.p.w>=p->b.x); + int yc = (mario.p.y-3==p->b.y); + + /*if (p->type==P_FALLING) + { + if (p->v) + p->v++; + p->b.y+=p->v/2; + }*/ + box_t temp=p->b; + + box_move(&p->b); + + // Si mario est sur la plateforme, il bouge avec if (xc&&yc) - mario.p.x+=t_v; - if (p->x+p->width > p->xmax && p->v>0) - p->v *= -1; - if (p->x < p->xmin && p->v<0) - p->v *= -1; -} + { + box_t mario_clone=mario.p; + mario_clone.vx=temp.vx; + mario_clone.vy=temp.vy; + box_move(&mario_clone); + mario.p.x=mario_clone.x; + mario.p.y=mario_clone.y; + } -if (p->type==P_MOVING_V) -{ - int s=sgn(p->v); - int t_v=((s*p->v+time_id%2)/2)*s; - if (p->v==0) - p->v=p->vinit; - p->y+=t_v; - if (p->y > p->ymax || p->y+3 < p->ymin) - p->v *= -1; -} - -if (xc&&yc) -{ - int s=sgn(p->v); - int t_v=((s*p->v+time_id%2)/2)*s; - if (p->type==P_FALLING) - mario.p.y+=p->v/2; - if (p->type==P_MOVING_V) - mario.p.y+=t_v; - if (p->type==P_MOVING_H) - mario.p.x+=t_v/2; -} + + if (p->b.vx==0) + { + p->b.vx=-temp.vx; + //p->b.x -= sgn(p->b.vx); + } + if (p->b.vy==0) + p->b.vy=-temp.vy; } void display_plateformes() @@ -91,9 +64,9 @@ void display_plateformes() for (int i=0; ix; j < p->x+p->width; j+=3) - draw_tile(j-camera_x(),p->y-camera_y(), &tplateforme, 0,0); - //drect(p->x-world_get_real_x0(),64-(p->y-world_get_real_y0()),p->x-world_get_real_x0()+p->width,64-(p->y-world_get_real_y0()-3), C_BLACK); + for (int j=p->b.x; j < p->b.x+p->b.w; j+=3) + draw_tile(j-camera_x(),p->b.y-camera_y(), &tplateforme, 0,0); + //drect(p->b.x-world_get_real_x0(),64-(p->b.y-world_get_real_y0()),p->b.x-world_get_real_x0()+p->b.w,64-(p->b.y-world_get_real_y0()-3), C_BLACK); } } @@ -116,7 +89,7 @@ int plateforme_check_collide(int x, int y) for (int i=0; ix<=x && p->x+p->width>x && p->y<=y && p->y+3>y) + if (p->b.x<=x && p->b.x+p->b.w>x && p->b.y<=y && p->b.y+3>y) return 1; } return 0; diff --git a/src/tile.c b/src/tile.c index a65be83..b88ade2 100755 --- a/src/tile.c +++ b/src/tile.c @@ -7,6 +7,8 @@ int dark_theme=0; extern image_t img_tuyau; const tileset_t tuyau={&img_tuyau, TILE_W, TILE_H, 1}; +extern image_t img_arbre; +const tileset_t arbre={&img_arbre, TILE_W, TILE_H, 0}; extern image_t img_brick; const tileset_t brick={&img_brick, TILE_W, TILE_H, 1}; diff --git a/src/world.c b/src/world.c index 6c59306..01b6e8b 100755 --- a/src/world.c +++ b/src/world.c @@ -51,6 +51,13 @@ void display_cell(int cx, int cy, int sx, int sy, int plan) draw_tile(sx, sy, &tuyau, i->x, i->y); } + if (cell->type==ARBRE) + { + arbre_t* i=(arbre_t*)cell; + draw_tile(sx, sy, &arbre, i->x, i->y); + } + + if (cell->type==EARTH) { earth_t* i=(earth_t*)cell; @@ -144,6 +151,12 @@ int world_get_ctg(int x, int y) } if (plateforme_check_collide(x,y)) return CTG_SOIL; + if (c->type==ARBRE) + { + arbre_t* a=(arbre_t*)c; + if (a->x==1&&a->y==1) + return CTG_EMPTY; + } switch (c->type) { case TUYAU: @@ -151,6 +164,7 @@ int world_get_ctg(int x, int y) case BRICK: case EARTH: case BLOC: + case ARBRE: return CTG_SOIL; default: return CTG_EMPTY; @@ -159,8 +173,8 @@ int world_get_ctg(int x, int y) void world_draw() { - //camera_move(0); - camera_adjust(); + camera_move(0); + //camera_adjust(); int mx0=camera_x(); int my0=camera_y(); int sx0=mx0%8;