diff --git a/SuperCbr.g1a b/SuperCbr.g1a index 91449f8..0934fb0 100644 Binary files a/SuperCbr.g1a and b/SuperCbr.g1a differ diff --git a/src/camera.c b/src/camera.c index fbbfd60..e52c352 100644 --- a/src/camera.c +++ b/src/camera.c @@ -1,4 +1,5 @@ #include + #include #include #include diff --git a/src/config.c b/src/config.c index 76c3c9f..f2a02cc 100644 --- a/src/config.c +++ b/src/config.c @@ -1,35 +1,15 @@ -#include "config.h" +#include + +#include #include + #include -#include #include -extern image_t img_tickbox; - -char loglevels[6][14]={"--all","--information","--warning","--critical","--fatal","--mute"}; - void configmenu() { MKB_clear(); - font_t const * const f=dfont(0); - while (1) - { - dclear(C_WHITE); - drect(0,0,128,7,C_BLACK); - dtext(0,0,"Configuration Menu : ", C_WHITE, C_NONE); - - dtext(0,9," > LOG", C_BLACK, C_NONE); - dtext(0,17," ", C_BLACK, C_NONE); - - dtext(40,9,&loglevels[ll_get_level()][0],C_BLACK,C_NONE); - dupdate(); - ll_pause(); - int key=MKB_getkey(); - if (key==KEY_EXIT) - break; - } + ll_pause(); MKB_clear(); - dfont(f); - -} \ No newline at end of file +} diff --git a/src/world.c b/src/world.c index 099df6a..0612711 100755 --- a/src/world.c +++ b/src/world.c @@ -1,19 +1,23 @@ -#include "world.h" -#include "tile.h" -#include "mario.h" -#include "ennemi.h" -#include -#include "bonus.h" -#include -#include "constants.h" -#include "ennemi.h" +#include + +#include +#include +#include +#include +#include + +#include +#include + +#include +#include #include #include #include -#include -#include -#include -#include + +#include + +#include #include #include @@ -43,129 +47,98 @@ void cellDraw(int cx, int cy, int sx, int sy, int plan) const cell_t * cell=worldGetCell(cx,cy); if (cell==0) return; - if (plan==1) + if (plan==1) switch (cell->type) { - if (cell->type==TUYAU) - { - tuyau_t* i=(tuyau_t*)cell; - tileDraw(sx, sy, &tuyau, i->x, i->y); - } + case TUYAU: + tileDraw(sx, sy, &tuyau, ((tuyau_t*)cell)->x, ((tuyau_t*)cell)->y); + break; - if (cell->type==ARBRE) - { - arbre_t* i=(arbre_t*)cell; - tileDraw(sx, sy, &arbre, i->x, i->y); - } + case ARBRE: + tileDraw(sx, sy, &arbre, ((arbre_t*)cell)->x, ((arbre_t*)cell)->y); + break; + case EARTH: + tileDraw(sx, sy, &earth, ((earth_t*)cell)->x, ((earth_t*)cell)->y); + break; - if (cell->type==EARTH) - { - earth_t* i=(earth_t*)cell; - tileDraw(sx, sy, &earth, i->x, i->y); - } - if (cell->type==BLOC) - { - tileDraw(sx, sy, &bloc, 0, 0); - } + case BLOC: + tileDraw(sx, sy, &bloc, 0, 0); + break; - if (cell->type==BLOC) + case BRICK: + if (((brick_t*)cell)->time_hit_id) // calculate collision animation { - tileDraw(sx, sy, &bloc, 0, 0); + ((brick_t*)cell)->time_hit_id++; // Next frame for the animation + sy+=2+(((brick_t*)cell)->time_hit_id-4)/4; // For the brick coordinate + if (((brick_t*)cell)->time_hit_id==8) ((brick_t*)cell)->time_hit_id=0; // End of animation + if (((brick_t*)cell)->state==1 && ((brick_t*)cell)->time_hit_id==0) ((brick_t*)cell)->type=0; // Delete brick } + if (!((brick_t*)cell)->hidden) + { + if (((brick_t*)cell)->time_hit_id || !((brick_t*)cell)->content || !((brick_t*)cell)->number) tileDraw(sx, sy, &brick, 0, ((brick_t*)cell)->state); + else tileDraw(sx, sy, &gift, 1, 0); + if (((brick_t*)cell)->content==1 && ((brick_t*)cell)->time_hit_id && ((brick_t*)cell)->time_hit_id<=4) tileDraw(sx, sy+8, &coin, 0, 0); + } + break; - if (cell->type==BRICK) + case GIFT: + if (((gift_t*)cell)->time_hit_id) { - brick_t* i=(brick_t*)cell; - if (i->time_hit_id) - { - i->time_hit_id++; - sy+=2+(i->time_hit_id-4)/4; - if (i->time_hit_id==8) - i->time_hit_id=0; - if (i->state==1 && i->time_hit_id==0) - i->type=0; - } - if (i->hidden==0) - { - if (i->time_hit_id || i->content==0 || i->number>0) - tileDraw(sx, sy, &brick, 0, i->state); - else - tileDraw(sx, sy, &gift, 1, 0); - if (i->content==1 && i->time_hit_id && i->time_hit_id<=4) - tileDraw(sx, sy+8, &coin, 0, 0); - } + ((gift_t*)cell)->time_hit_id++; + sy+=2+(((gift_t*)cell)->time_hit_id-4)/4; + if (((gift_t*)cell)->time_hit_id==8) ((gift_t*)cell)->time_hit_id=0; } - - if (cell->type==GIFT) + if (((gift_t*)cell)->hidden==0) { - gift_t* i=(gift_t*)cell; - if (i->time_hit_id) - { - i->time_hit_id++; - sy+=2+(i->time_hit_id-4)/4; - if (i->time_hit_id==8) - i->time_hit_id=0; - } - if (i->hidden==0) - { - if (i->time_hit_id || i->number) - tileDraw(sx, sy, &gift, 0, 0); - else - tileDraw(sx, sy, &gift, 1, 0); - if (i->content==1 && i->time_hit_id && i->time_hit_id<=4) - tileDraw(sx, sy+8, &coin, 0, 0); - } + if (((gift_t*)cell)->time_hit_id || ((gift_t*)cell)->number) tileDraw(sx, sy, &gift, 0, 0); + else tileDraw(sx, sy, &gift, 1, 0); + if (((gift_t*)cell)->content==1 && ((gift_t*)cell)->time_hit_id && ((gift_t*)cell)->time_hit_id<=4) tileDraw(sx, sy+8, &coin, 0, 0); } + break; } - else + else switch (cell->type) { - if (cell->type==COIN) - { - coin_t const * i=(coin_t*)cell; - tileDraw(sx, sy, &coin, i->taken, 0); - } + case COIN: + tileDraw(sx, sy, &coin, ((coin_t*)cell)->taken, 0); + break; - if (cell->type==BUISSON || cell->type==NUAGE || cell->type==COLLINE || cell->type==CASTLE || cell->type==END_LEVEL) - { - deco_t* i=(deco_t*)cell; - if (i->type==BUISSON) - tileDraw(sx, sy, &buisson, i->x, i->y); - if (i->type==NUAGE) - tileDraw(sx, sy, &nuage, i->x, i->y); - if (i->type==COLLINE) - tileDraw(sx, sy, &colline, i->x, i->y); - if (i->type==CASTLE) - tileDraw(sx, sy, &castle, i->x, i->y); - if (i->type==END_LEVEL) - tileDraw(sx-8, sy, &end_level, 0, i->y); - } + case BUISSON: + tileDraw(sx, sy, &buisson, ((deco_t*)cell)->x, ((deco_t*)cell)->y); + break; + + case NUAGE: + tileDraw(sx, sy, &nuage, ((deco_t*)cell)->x, ((deco_t*)cell)->y); + break; + + case COLLINE: + tileDraw(sx, sy, &colline, ((deco_t*)cell)->x, ((deco_t*)cell)->y); + break; + + case CASTLE: + tileDraw(sx, sy, &castle, ((deco_t*)cell)->x, ((deco_t*)cell)->y); + break; + + case END_LEVEL: + tileDraw(sx, sy, &end_level, ((deco_t*)cell)->x, ((deco_t*)cell)->y); + break; } } int worldGetCellCategory(int x, int y) { - cell_t *c=worldGetCell(x,y); - if (c==0) - { - return CTG_DEATH; - } - if (platformsCollisionTest(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; - } + cell_t *c=worldGetCell(x,y); // get cell props + + if (c==0) return CTG_DEATH; // out of the map + + if (platformsCollisionTest(x,y)) return CTG_SOIL; // tested point is a platform + + if (c->type==ARBRE && (((arbre_t*)c)->x==1&&((arbre_t*)c)->y==1)) return CTG_EMPTY; // tree trunk + switch (c->type) { - case TUYAU: - case GIFT: - case BRICK: - case EARTH: - case BLOC: - case ARBRE: + case TUYAU: case GIFT: case BRICK: case EARTH: case BLOC: case ARBRE: return CTG_SOIL; + default: return CTG_EMPTY; } @@ -173,19 +146,17 @@ int worldGetCellCategory(int x, int y) void worldDraw() { - cameraMove(0); - //cameraAdjust(); - int mx0=cameraX(); - int my0=cameraY(); - int sx0=mx0%8; - int sy0=my0%8; + cameraMove(); + + const int mx0=cameraX(), my0=cameraY(); + const int sx0=mx0%8, sy0=my0%8; //background tiles for (int i=0, mx=mx0; i<=17; i++, mx+=8) for (int j=0, my=my0; j<=9; j++, my+=8) cellDraw(mx, my, 8*i-sx0, 8*j-sy0,0); + // animated items bonusDraw(); ennemiesDisplay(); - bulletsDraw(); platformsDraw(); marioDraw(); @@ -193,18 +164,14 @@ void worldDraw() //foreground tiles for (int i=0, mx=mx0; i<=17; i++, mx+=8) for (int j=0, my=my0; j<=9; j++, my+=8) cellDraw(mx, my, 8*i-sx0, 8*j-sy0,1); - // draw immunity remaining time - // It's a progress bar on the left side + // draw immunity remaining time [It's a progress bar on the left side of the screen] if (mario_immunity) drect(0,64-MARIO_IMMUNITY_TIME+mario_immunity,2,64, C_BLACK); } void worldMove() { MKB_update(); - for (int i=0; iw = w;