global code cleaning, especially with function names

dev 0.5
Milang 3 years ago
parent 0c527962ab
commit 7138dd442c
  1. BIN
      SuperCbr.g1a
  2. 4
      include/base.h
  3. 13
      include/bonus.h
  4. 11
      include/box.h
  5. 12
      include/bullets.h
  6. 16
      include/camera.h
  7. 12
      include/constants.h
  8. 19
      include/ennemi.h
  9. 10
      include/framerate.h
  10. 10
      include/keyboard.h
  11. 16
      include/level.h
  12. 4
      include/levelchanger.h
  13. 24
      include/mario.h
  14. 27
      include/plateforme.h
  15. 18
      include/save.h
  16. 31
      include/score.h
  17. 2
      include/tile.h
  18. 10
      include/tuyau.h
  19. 25
      include/world.h
  20. 4
      levelconverter/levelconv.py
  21. 4
      src/base.c
  22. 46
      src/bonus.c
  23. 34
      src/box.c
  24. 16
      src/bullet.c
  25. 30
      src/camera.c
  26. 6
      src/config.c
  27. 86
      src/ennemi.c
  28. 6
      src/framerate.c
  29. 20
      src/keyboard.c
  30. 192
      src/level.c
  31. 88
      src/levelchanger.c
  32. 4
      src/main.c
  33. 146
      src/mario.c
  34. 54
      src/plateforme.c
  35. 18
      src/save.c
  36. 36
      src/score.c
  37. 2
      src/tile.c
  38. 70
      src/tuyau.c
  39. 129
      src/world.c

Binary file not shown.

@ -11,8 +11,8 @@ int sgn(const int x);
int abs(const int x);
void* malloc_prof(int size);
void* mallocProf(int size);
void free_prof(void * p);
void freeProf(void * p);
#endif

@ -1,6 +1,5 @@
// v0.3
#ifndef BONUS_H
#define BONUS_H
#define BONUS_H
#include <box.h>
@ -16,17 +15,17 @@ typedef enum
BONUS_STAR
} bonus_id; // TODO add fragment
typedef struct
typedef struct
{
int type;
box_t b;
int p1;
} bonus_t;
void bonus_set(bonus_id t, int x, int y);
void bonusSet(bonus_id t, int x, int y);
void bonus_draw();
void bonusDraw();
void bonus_move();
void bonusMove();
#endif
#endif

@ -1,7 +1,8 @@
// v0.3
#ifndef BOX_H
#define BOX_H
#include <stdbool.h>
// Box type
// Used to simulate gravity and collides
@ -17,11 +18,11 @@ typedef struct
int vy :8;
int last_vy :8;
int gravity :8;
//int is_mario;
//int isMario;
} box_t;
void box_move(box_t * b);
int BoxContact(box_t const * b1, box_t const * b2);
void box_jump(box_t * b, int height);
void boxMove(box_t * b);
bool boxContact(box_t const * b1, box_t const * b2);
void boxJump(box_t * b, int height);
#endif

@ -1,4 +1,3 @@
// v0.3
#ifndef BULLETS_H
#define BULLETS_H
@ -6,10 +5,13 @@
// two maximum on the screen (static)
// destroys ennemies, and is destroyed when it hits a wall
void bullet_throw();
// if there are less than two fire bullets on the screen, create a new bullet
void bulletThrow();
void bullet_display();
// draw bullets on the screen
void bulletsDraw();
void bullet_move();
// move bullets and check collisions
void bulletsMove();
#endif
#endif

@ -2,19 +2,19 @@
#define CAMERA_H
// Top left corner coordinates
int camera_x();
int camera_y();
int cameraX();
int cameraY();
/* Auto track mario,
The delay is custom:
/* Auto track mario,
The delay is custom:
0 default
1 to follow perfectly mario, no delay
the higher the delay is, the longest time the camera takes to go to mario (recommended as inferior to 6)
*/
void camera_move(int delay);
void cameraMove();
void camera_reset(); // Reset camera to (0,0)
void cameraReset(); // Reset camera to (0,0)
void camera_adjust(); // Set camera on mario -> useful when there is a pipe, for example
void cameraAdjust(); // Set camera on mario -> useful when there is a pipe, for example
#endif
#endif

@ -1,3 +1,7 @@
#ifndef CONSTANTS_H
#define CONSTANTS_H
#define TILE_W 8
#define TILE_H 8
@ -5,7 +9,9 @@
#define SCREEN_H 64
#include <stdbool.h>
extern bool dark_theme_enable;
extern bool is_in_water;
//extern bool dark_theme_enable;
//extern bool is_in_water;
extern int frame_id;
extern int frame_id;
#endif // CONSTANTS_H

@ -1,8 +1,5 @@
#ifndef ENNEMI_H
#define ENNEMI_H
#define ENNEMI_H
#include "box.h"
#define NOMBRE_ENNEMIS 6
@ -16,7 +13,7 @@ extern const int ennemi_heights[NOMBRE_ENNEMIS];
#define KOOPA_V_ID 2
#define CARAPACE_VERTE 3
#define KOOPA_R_ID 4
#define CARAPACE_ROUGE 5
#define CARAPACE_ROUGE 5
#define GOOMBA(x,y,dir) {GOOMBA_ID,{x,y,ennemi_widths[GOOMBA_ID],ennemi_heights[GOOMBA_ID],dir,0,0,1},1,0,dir}
#define KOOPA_V(x,y,dir) {KOOPA_V_ID,{x,y,ennemi_widths[KOOPA_V_ID],ennemi_heights[KOOPA_V_ID],dir,0,0,1},1,0,dir}
@ -27,7 +24,7 @@ extern const int ennemi_heights[NOMBRE_ENNEMIS];
// Dimensions pr les boites
typedef struct
typedef struct
{
int type :8;
box_t b;
@ -36,14 +33,14 @@ typedef struct
int p1 :14;
} ennemi_t;
void display_ennemi(ennemi_t * e);
void ennemiDisplay(ennemi_t * e);
extern ennemi_t * ennemis_global;
extern int ennemis_global_size;
void display_ennemi_table();
void ennemiesDisplay();
void move_ennemi(ennemi_t *e);
void ennemiMove(ennemi_t *e);
void init_ennemi(ennemi_t * table, int s);
void EnnemiesInit(ennemi_t * table, int s);
#endif
#endif

@ -1,12 +1,12 @@
#ifndef FRAMERATE_H
#define FRAMERATE_H
#define FRAMERATE_H
// Defined to 20 FPS, constant
void init_refresh();
void initRefreshTimer();
void quit_refresh();
void quitRefreshTimer();
void wait_next_frame();
void waitNextFrame();
#endif
#endif

@ -15,7 +15,7 @@ typedef enum
MK_UP,
MK_JUMP, // Shift
MK_RUN // Alpha
} mkb_t;
} MKB_t;
/* This function has been coded to replace the following array
`extern mkey_t keys[6];`
@ -24,16 +24,16 @@ typedef enum
1=currently down
0=up
*/
int mkb_getstate(mkb_t const k);
int MKB_getKeyState(MKB_t const k);
// Update the keyboard, should be called at each frame
void mkb_update();
void MKB_update();
// Reset followed keys' states
void mkb_clear();
void MKB_clear();
// Experimental getkey, designed to compensate for a strange bug introduced by original getkey
// /!\ return gint keycodes
int mkb_getkey();
int MKB_getkey();
#endif

@ -1,26 +1,26 @@
#ifndef LEVEL_H
#define LEVEL_H
#define LEVEL_H
// Utilitaire de décompression de level
#include <stdint.h>
typedef struct
typedef struct
{
uint8_t width;
uint8_t width;
uint8_t height;
uint8_t data[]; // rough data
} packed_level_t;
//void unpack_level(packed_level_t const * const packed_level_t);
//void unpackLevel(packed_level_t const * const packed_level_t);
void set_level(int w, int l); // Configures the level
void setLevel(int w, int l); // Configures the level
void get_lvl_id(int w, int l, char * str); // Retruns level ID into a char [4]
void getLevelID(int w, int l, char * str); // Retruns level ID into a char [4]
void malloc_error();
void mallocError();
#endif
#endif

@ -1,6 +1,6 @@
#ifndef LEVEL_CHANGE_H
#define LEVEL_CHANGE_H
void LaunchUI();
void launchUI();
#endif
#endif

@ -10,8 +10,11 @@
#define M_RIGHT2 3
#define M_WALK 0
#define M_LITTLE 1
#define M_SWIM 2
//#define M_LITTLE 1
//#define M_SWIM 2
#define MARIO_IMMUNITY_TIME 60
// 60/20 seconds = 3 seconds
#include "box.h"
@ -26,27 +29,28 @@ typedef struct
extern pnj mario;
extern int coins;
void mario_draw();
void marioDraw();
//void mario_physics();
void mario_jump();
void marioJump();
void resetMarioJump(); // resets coyote time & jump buffering (used by teleporters)
void marioMove();
void mario_move();
void ResetMarioJump();
void mario_bigger();
void mario_smaller();
void marioBigger();
void marioSmaller();
extern int global_quit;
extern int numero_frame;
extern int mario_x_max;
extern int mario_xMax;
extern int mario_dead;
extern int id_frame;
extern int mario_immunity;
extern int mario_has_bullets;
extern int last_vx_sign;
extern int mario_star_mode;
extern int mario_starMode;
#endif

@ -8,7 +8,7 @@
#include <box.h>
typedef struct
typedef struct
{
unsigned type;
int xinit, yinit;
@ -25,29 +25,26 @@ typedef struct
};
int counter;
box_t b;
} plateforme_t;
} plateform_t;
#define PLATEFORME_HEIGHT 3
// Init macros
#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);
void platformsMove();
void platformsDraw();
int platformsCollisionTest(int x, int y);
//void move_plateforme(plateforme_t* p); // touch mario stuff
void platformsInit(plateform_t * table, int s);
void move_plateformes();
/*
extern int plateform_table_size;
extern plateform_t* plateformes;
*/
void display_plateformes();
int plateforme_check_collide(int x, int y);
void init_plateformes(plateforme_t * table, int s);
extern int plateforme_table_size;
extern plateforme_t* plateformes;
#endif
#endif

@ -4,19 +4,19 @@
#define WORLD_RUN_ENTRY 9 // 8 niveaux + mode run
#define NB_MONDES 5
void load_save(); // Ho calme toi pas tt de suite ! Utilisera BFile lorsque le header de gint sera complété
void flash_save(); // Non plus :E
void saveLoad(); // Not yet ! will use BFile
void saveWrite(); // neither :E
int get_highscore(int world, int level);
void set_highscore(int world, int level, unsigned int score);
int saveGetScore(int world, int level); // return the highest score for the correspondig challenge
void saveSetScore(int world, int level, unsigned int score);
int get_best_time(int world, int level);
void set_best_time(int world, int level, unsigned int time);
int saveGetTime(int world, int level); // return the lowest time for the corresponding challenge
void saveSetTime(int world, int level, unsigned int time);
int get_highcoins(int world, int level);
void set_highcoins(int world, int level, unsigned int coins);
int saveGetCoins(int world, int level); // return the highest number of coins for the correspondig challenge
void saveSetCoins(int world, int level, unsigned int coins);
unsigned int GetProgressStatus();
unsigned int saveGetProgressStatus();
#endif

@ -6,24 +6,27 @@
//extern int score;
//extern int lifes;
extern int finish_level; // si ==-1, continue, si 0==retry, si ==1 ou + next
extern int time_id;
extern unsigned int time_id;
int get_score();
int get_coins();
void score_reset();
void score_add(int);
void score_display();
void score_add_coin();
void new_level();
void new_game();
int coinsGet();
void coinAdd();
int scoreGet();
void scoreReset();
void scoreAdd(int);
int get_time_spent();
void scoreDisplay(); // display time, score & coins
/* Lifes Management */
void levelNew();
void gameNew();
int LifesGet();
void LifesSet(int);
void LifesAdd(int);
int getTimeSpent();
/* lifes Management */
int lifesGet();
void lifesSet(int);
void lifesAdd(int);
#endif

@ -40,6 +40,6 @@ extern const tileset_t mario_big;
extern const tileset_t tplateforme;
void draw_tile(int sx, int sy, tileset_t const * const set, int x, int y);
void tileDraw(int sx, int sy, tileset_t const * const set, int x, int y);
#endif

@ -1,15 +1,15 @@
#ifndef TUYAU_H
#define TUYAU_H
#define TUYAU_H
typedef struct
typedef struct
{
int x, y; // En cases de 8*8
int tx, ty; // Targeted coords
int key; // Key used (may be -1 if the user doesn't have to press any key)
} teleport_t;
void set_teleporteurs(teleport_t const * const t, int const n);
void teleportersSet(teleport_t const * const t, unsigned int const n);
void teleport_active(); // Activation des teleporteurs à chaque frame
void teleportersActive(); // Activation des teleporteurs à chaque frame
#endif
#endif

@ -8,7 +8,7 @@
#define W_SIZE_X 160
#define W_SIZE_Y 16
typedef enum
typedef enum
{
EMPTY=0,
EARTH,
@ -109,31 +109,24 @@ typedef struct
unsigned data :24; // raw binary format
} cell_t;
int world_get_width();
int worldGetWidth();
cell_t* world_get(int x, int y);
cell_t* worldGetCell(int x, int y);
void display_cell(int cx, int cy, int sx, int sy, int plan);
void cellDraw(int cx, int cy, int sx, int sy, int plan);
void world_set(int w, int h, int x, int y, cell_t const * a);
void worldSet(int w, int h, int x, int y, cell_t const * a);
void world_draw();
void world_move();
void worldDraw();
void worldMove();
int world_get_real_x0();
int world_get_real_y0();
void world_reset();
void worldReset();
#define CTG_SOIL 1
#define CTG_EMPTY 2
#define CTG_WATER 3
#define CTG_DEATH 4
int world_get_ctg(int x, int y);
void reset_camera();
void init_level(int w, int h, int x, int y, cell_t const * a);
int worldGetCellCategory(int x, int y);
typedef struct
{

@ -13,7 +13,7 @@ boite_piece = (255, 153, 0)
boite_champi = (204, 0, 255)
brique_piece = (101, 127, 0)
beton = (84, 84, 84)
tuyau_milieu = (0, 255, 102)
tuyauMilieu = (0, 255, 102)
tuyau_bout = (50, 255, 0)
drapeau = (0, 255, 216)
goomba = (127, 76, 0)
@ -82,7 +82,7 @@ for x in range(0,img.size[0]):
elif color_compare(pixels[x,y],tuyau_bout):
code += write_char(8)
elif color_compare(pixels[x,y], tuyau_milieu):
elif color_compare(pixels[x,y], tuyauMilieu):
code += write_char(9)
elif color_compare(pixels[x,y], drapeau):

@ -27,7 +27,7 @@ int abs(const int x)
static int ram_used=0;
void* malloc_prof(int size)
void* mallocProf(int size)
{
void* p=malloc(size);
if (p)
@ -41,7 +41,7 @@ void* malloc_prof(int size)
return p;
}
void free_prof(void * p)
void freeProf(void * p)
{
free(p);
ll_sendp(LEVEL_INFO, "\n[std] free called");

@ -12,7 +12,7 @@
static bonus_t bonus ={BONUS_NONE, {0,0,TILE_W,TILE_H,0,0,0,1}, 0};
void bonus_set(bonus_id t, int x, int y)
void bonusSet(bonus_id t, int x, int y)
{
bonus.type=t;
if (mario.size==M_BIG && t==BONUS_CHAMPI)
@ -24,16 +24,16 @@ void bonus_set(bonus_id t, int x, int y)
bonus.p1=0;
}
void bonus_move() //+collision
void bonusMove() //+collision
{
if (bonus.type==BONUS_NONE)
return;
if (bonus.type==BONUS_STAR)
{
box_jump(&bonus.b,4);
boxJump(&bonus.b,4);
}
box_move(&bonus.b);
boxMove(&bonus.b);
if (bonus.type==BONUS_CHAMPI || bonus.type==BONUS_1UP || bonus.type==BONUS_STAR)
{
@ -51,50 +51,50 @@ void bonus_move() //+collision
}
}
if (bonus.b.y<0)
bonus_set(BONUS_NONE,0,0);
bonusSet(BONUS_NONE,0,0);
}
int collide=BoxContact(&mario.p, &bonus.b);
int collide=boxContact(&mario.p, &bonus.b);
if (collide)
{
if (bonus.type==BONUS_CHAMPI)
{
bonus_set(BONUS_NONE,0,0);
score_add(1000);
mario_bigger();
bonusSet(BONUS_NONE,0,0);
scoreAdd(1000);
marioBigger();
}
if (bonus.type==BONUS_FLEUR)
{
bonus_set(BONUS_NONE,0,0);
bonusSet(BONUS_NONE,0,0);
mario_has_bullets=1;
score_add(1000);
scoreAdd(1000);
}
if (bonus.type==BONUS_1UP)
{
bonus_set(BONUS_NONE,0,0);
score_add(1000);
LifesAdd(1);
bonusSet(BONUS_NONE,0,0);
scoreAdd(1000);
lifesAdd(1);
}
if (bonus.type==BONUS_STAR)
{
bonus_set(BONUS_NONE,0,0);
score_add(1000);
mario_star_mode=1;
bonusSet(BONUS_NONE,0,0);
scoreAdd(1000);
mario_starMode=1;
}
}
}
void bonus_draw()
void bonusDraw()
{
//bonus_move();
//bonusMove();
if (bonus.type==BONUS_NONE)
return;
if (bonus.type==BONUS_CHAMPI)
draw_tile(bonus.b.x-camera_x(), bonus.b.y-camera_y(), &champi, 0,0);
tileDraw(bonus.b.x-cameraX(), bonus.b.y-cameraY(), &champi, 0,0);
if (bonus.type==BONUS_FLEUR)
draw_tile(bonus.b.x-camera_x(), bonus.b.y-camera_y(), &fleur, 0,0);
tileDraw(bonus.b.x-cameraX(), bonus.b.y-cameraY(), &fleur, 0,0);
if (bonus.type==BONUS_1UP)
draw_tile(bonus.b.x-camera_x(), bonus.b.y-camera_y(), &life_1up, 0,0);
tileDraw(bonus.b.x-cameraX(), bonus.b.y-cameraY(), &life_1up, 0,0);
if (bonus.type==BONUS_STAR)
draw_tile(bonus.b.x-camera_x(), bonus.b.y-camera_y(), &mario_starman, 0,0);
tileDraw(bonus.b.x-cameraX(), bonus.b.y-cameraY(), &mario_starman, 0,0);
}

@ -7,11 +7,11 @@
int check_collision(box_t *b)
{
for (int i=0; i<ennemis_global_size; i++) if (BoxContact(&ennemis_global[i].b,b)) return 1;
for (int i=0; i<ennemis_global_size; i++) if (boxContact(&ennemis_global[i].b,b)) return 1;
return 0;
}
int BoxContact(box_t const * b1, box_t const * b2)
bool boxContact(box_t const * b1, box_t const * b2)
{
if (b1==b2) return 0;/*
bool x_collide= (mario.p.x<=e->b.x && e->b.x<=mario.p.x+mario.p.w-1) || (mario.p.x<=e->b.x+e->b.w-1 && e->b.x+e->b.w-1<=mario.p.x+mario.p.w-1);
@ -34,7 +34,7 @@ static void move_x(box_t * b)
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)
if (worldGetCellCategory(b->x, b->y)==CTG_WATER || worldGetCellCategory(b->x+b->w-1, b->y)==CTG_WATER)
coef=2;//ralentir dans l'eau
if (frame_id%coef)
return;
@ -47,9 +47,9 @@ static void move_x(box_t * b)
{
int typetemp;
if (sgn_vx>0)
typetemp=world_get_ctg(b->x+b->w-1+i*sgn_vx,b->y+j);
typetemp=worldGetCellCategory(b->x+b->w-1+i*sgn_vx,b->y+j);
else
typetemp=world_get_ctg(b->x+i*sgn_vx,b->y+j);
typetemp=worldGetCellCategory(b->x+i*sgn_vx,b->y+j);
if (typetemp==CTG_SOIL)
{
b->x+=(i-1)*sgn_vx;
@ -71,7 +71,7 @@ static void move_y(box_t * b)
int sgn_vy=sgn(b->vy);
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)
if (worldGetCellCategory(b->x, b->y)==CTG_WATER || worldGetCellCategory(b->x+b->w-1, b->y)==CTG_WATER)
coef=2;// 0.5
if (frame_id%coef)
return;
@ -84,26 +84,26 @@ static void move_y(box_t * b)
{
int typetemp;
if (sgn_vy>0)
typetemp=world_get_ctg(b->x+j ,b->y+b->h-1+i);
typetemp=worldGetCellCategory(b->x+j ,b->y+b->h-1+i);
else
typetemp=world_get_ctg(b->x+j ,b->y-i);
typetemp=worldGetCellCategory(b->x+j ,b->y-i);
if (typetemp==CTG_SOIL)
{
if (b->vy>0)
{
int old=b->x;
if (world_get_ctg(b->x+2, b->y+b->h-1+i)==CTG_SOIL && world_get_ctg(b->x+3, b->y+b->h-1+i)==CTG_EMPTY)
if (worldGetCellCategory(b->x+2, b->y+b->h-1+i)==CTG_SOIL && worldGetCellCategory(b->x+3, b->y+b->h-1+i)==CTG_EMPTY)
b->x++;
if (world_get_ctg(b->x+1, b->y+b->h-1+i)==CTG_SOIL && world_get_ctg(b->x+2, b->y+b->h-1+i)==CTG_EMPTY)
if (worldGetCellCategory(b->x+1, b->y+b->h-1+i)==CTG_SOIL && worldGetCellCategory(b->x+2, b->y+b->h-1+i)==CTG_EMPTY)
b->x++;
if (world_get_ctg(b->x, b->y+b->h-1+i)==CTG_SOIL && world_get_ctg(b->x+1, b->y+b->h-1+i)==CTG_EMPTY)
if (worldGetCellCategory(b->x, b->y+b->h-1+i)==CTG_SOIL && worldGetCellCategory(b->x+1, b->y+b->h-1+i)==CTG_EMPTY)
b->x++;
if (world_get_ctg(b->x+b->w-3, b->y+b->h-1+i)==CTG_SOIL && world_get_ctg(b->x+b->w-4, b->y+b->h-1+i)==CTG_EMPTY)
if (worldGetCellCategory(b->x+b->w-3, b->y+b->h-1+i)==CTG_SOIL && worldGetCellCategory(b->x+b->w-4, b->y+b->h-1+i)==CTG_EMPTY)
b->x--;
if (world_get_ctg(b->x+b->w-2, b->y+b->h-1+i)==CTG_SOIL && world_get_ctg(b->x+b->w-3, b->y+b->h-1+i)==CTG_EMPTY)
if (worldGetCellCategory(b->x+b->w-2, b->y+b->h-1+i)==CTG_SOIL && worldGetCellCategory(b->x+b->w-3, b->y+b->h-1+i)==CTG_EMPTY)
b->x--;
if (world_get_ctg(b->x+b->w-1, b->y+b->h-1+i)==CTG_SOIL && world_get_ctg(b->x+b->w-2, b->y+b->h-1+i)==CTG_EMPTY)
if (worldGetCellCategory(b->x+b->w-1, b->y+b->h-1+i)==CTG_SOIL && worldGetCellCategory(b->x+b->w-2, b->y+b->h-1+i)==CTG_EMPTY)
b->x--;
if (old==b->x)
{
@ -129,14 +129,14 @@ static void move_y(box_t * b)
}
void box_move(box_t * b)
void boxMove(box_t * b)
{
//velx
move_x(b);
move_y(b);
}
void box_jump(box_t * b, int height)
void boxJump(box_t * b, int height)
{
int sgn_vy=-1*sgn(height);
if (sgn_vy)
@ -144,7 +144,7 @@ void box_jump(box_t * b, int height)
int sol=0, eau=0;
for (int j=0; j<b->w; j++)
{
int typetemp=world_get_ctg(b->x+j ,b->y+sgn_vy);
int typetemp=worldGetCellCategory(b->x+j ,b->y+sgn_vy);
if (typetemp==CTG_SOIL)
sol++;
if (typetemp==CTG_WATER)

@ -15,7 +15,7 @@ static bonus_t bullets[2] =
{0, {0,0,TILE_W/2,TILE_H/2,0,0,0,1}, 0}
};
void bullet_throw()
void bulletThrow()
{
for (int i=0; i<2; i++)
{
@ -35,28 +35,28 @@ void bullet_throw()
}
}
void bullet_display()
void bulletsDraw()
{
for (int i=0; i<2; i++)
{
if (bullets[i].type==1)
draw_tile(bullets[i].b.x-camera_x(), bullets[i].b.y-camera_y(), &bullet, (1+sgn(bullets[i].b.vy))/2, 0);
tileDraw(bullets[i].b.x-cameraX(), bullets[i].b.y-cameraY(), &bullet, (1+sgn(bullets[i].b.vy))/2, 0);
}
}
void bullet_move()
void bulletsMove()
{
for (int i=0; i<2; i++)
{
if (bullets[i].type==1)
{
box_jump(&bullets[i].b,4);
box_move(&bullets[i].b);
boxJump(&bullets[i].b,4);
boxMove(&bullets[i].b);
if (bullets[i].b.vx==0)
bullets[i].type=0;
if (bullets[i].b.y<0)
bullets[i].type=0;
if (bullets[i].b.x<=camera_x()-bullets[i].b.w || bullets[i].b.x>=camera_x()+127)
if (bullets[i].b.x<=cameraX()-bullets[i].b.w || bullets[i].b.x>=cameraX()+127)
bullets[i].type=0;
for (int a=0; a<ennemis_global_size; a++)
{
@ -69,7 +69,7 @@ void bullet_move()
{
t->life=DEAD;
bullets[i].type=0;
score_add(KILL_ENNEMI);
scoreAdd(KILL_ENNEMI);
break;
}
}

@ -5,40 +5,40 @@
static int y=0;
int camera_x() {return min(max(mario.p.x-40,0),map_current->w*8-128);}
int camera_y() {return max(y-32,0);}
int cameraX() {return min(max(mario.p.x-40,0),map_current->w*8-128);}
int cameraY() {return max(y-32,0);}
static int immobile=0;
static int last_vy=0;
static int distance=0;
void camera_move(int delay) // movement vertical seulement
void cameraMove() // movement vertical seulement
{
/* static int is_moving=0;
/* static int isMoving=0;
static int ref_y=0;
if (mario.p.y-camera_y()<16 || mario.p.y-camera_y()>56)
if (mario.p.y-cameraY()<16 || mario.p.y-cameraY()>56)
{
is_moving=1;
isMoving=1;
ref_y=mario.p.y;
}
if (is_moving)
if (isMoving)
{
for (int i=0; i<9; i++)
y+=sgn(mario.p.y-y);
if (y==ref_y)
is_moving=0;
isMoving=0;
}
*/
*/
static int camera_vy=0;
if (mario.p.y==last_vy) // mario arrêté
immobile++;
else
else
{
last_vy=mario.p.y;
immobile=0;
}
if (mario.p.y-camera_y()-mario.p.h<16 || mario.p.y-camera_y()>54)
if (mario.p.y-cameraY()-mario.p.h<16 || mario.p.y-cameraY()>54)
{
y+=5*sgn(mario.p.y-y);
}
@ -68,17 +68,17 @@ void camera_move(int delay) // movement vertical seulement
}
else
y+=(camera_vy*sgn(mario.p.y-y))/2;
}
last_vy=mario.p.y;
}
void camera_adjust()
void cameraAdjust()
{
y=mario.p.y;
}
void camera_reset()
void cameraReset()
{
y=0;
}
}

@ -11,7 +11,7 @@ char loglevels[6][14]={"--all","--information","--warning","--critical","--fatal
void configmenu()
{
mkb_clear();
MKB_clear();
font_t const * const f=dfont(0);
while (1)
{
@ -25,11 +25,11 @@ void configmenu()
dtext(40,9,&loglevels[ll_get_level()][0],C_BLACK,C_NONE);
dupdate();
ll_pause();
int key=mkb_getkey();
int key=MKB_getkey();
if (key==KEY_EXIT)
break;
}
mkb_clear();
MKB_clear();
dfont(f);
}

@ -14,7 +14,7 @@
const int ennemi_widths [NOMBRE_ENNEMIS] = {0, 8, 8, 8, 8 , 8};
const int ennemi_heights[NOMBRE_ENNEMIS] = {0, 8, 12, 9, 12, 9};
void display_ennemi(ennemi_t * e)
void ennemiDisplay(ennemi_t * e)
{
if (e->life==0)
{
@ -32,7 +32,7 @@ void display_ennemi(ennemi_t * e)
}
if (e->type==NONE)
return;
if (e->b.x<=camera_x(0)-e->b.w || e->b.x>=camera_x(0)+127)
if (e->b.x<=cameraX(0)-e->b.w || e->b.x>=cameraX(0)+127)
return;
else
e->discovered=1;
@ -42,54 +42,54 @@ void display_ennemi(ennemi_t * e)
extern image_t img_goomba;
tileset_t goomba={&img_goomba, ennemi_widths[GOOMBA_ID], ennemi_heights[GOOMBA_ID], 1};
if (e->life==1)
draw_tile(e->b.x-camera_x(0), e->b.y-camera_y(mario.p.y), &goomba, 1+(time_id/10)%2, 0);
tileDraw(e->b.x-cameraX(0), e->b.y-cameraY(mario.p.y), &goomba, 1+(time_id/10)%2, 0);
if (e->life==0)
draw_tile(e->b.x-camera_x(0), e->b.y-camera_y(mario.p.y), &goomba, 0, 0);
tileDraw(e->b.x-cameraX(0), e->b.y-cameraY(mario.p.y), &goomba, 0, 0);
}
if (e->type==KOOPA_V_ID)
{
extern image_t img_koopa_verte;
tileset_t koopa_verte={&img_koopa_verte, ennemi_widths[KOOPA_V_ID], ennemi_heights[KOOPA_V_ID], 1};
if (e->life==1)
draw_tile(e->b.x-camera_x(0), e->b.y-camera_y(mario.p.y), &koopa_verte, (1+e->p1)+(time_id/8)%2, 0);
tileDraw(e->b.x-cameraX(0), e->b.y-cameraY(mario.p.y), &koopa_verte, (1+e->p1)+(time_id/8)%2, 0);
}
if (e->type==KOOPA_R_ID)
{
extern image_t img_koopa_rouge;
tileset_t koopa_rouge={&img_koopa_rouge, ennemi_widths[KOOPA_R_ID], ennemi_heights[KOOPA_R_ID], 1};
if (e->life==1)
draw_tile(e->b.x-camera_x(0), e->b.y-camera_y(mario.p.y), &koopa_rouge, (1+e->p1)+(time_id/8)%2, 0);
tileDraw(e->b.x-cameraX(0), e->b.y-cameraY(mario.p.y), &koopa_rouge, (1+e->p1)+(time_id/8)%2, 0);
}
if (e->type==CARAPACE_VERTE)
{
extern image_t img_carapace_verte;
tileset_t carapace_verte={&img_carapace_verte, ennemi_widths[CARAPACE_VERTE], ennemi_heights[CARAPACE_VERTE], 1};
draw_tile(e->b.x-camera_x(0), e->b.y-camera_y(mario.p.y), &carapace_verte, 0, 0);
tileDraw(e->b.x-cameraX(0), e->b.y-cameraY(mario.p.y), &carapace_verte, 0, 0);
}
if (e->type==CARAPACE_ROUGE)
{
extern image_t img_carapace_rouge;
tileset_t carapace_rouge={&img_carapace_rouge, ennemi_widths[CARAPACE_ROUGE], ennemi_heights[CARAPACE_ROUGE], 1};
draw_tile(e->b.x-camera_x(0), e->b.y-camera_y(mario.p.y), &carapace_rouge, 0, 0);
tileDraw(e->b.x-cameraX(0), e->b.y-cameraY(mario.p.y), &carapace_rouge, 0, 0);
}
}
bool ennemi_check_collision(ennemi_t *e) { return (BoxContact(&e->b, &mario.p)); }
bool ennemi_check_collision(ennemi_t *e) { return (boxContact(&e->b, &mario.p)); }
void hurt_mario()
void hurtMario()
{ if (mario.size==M_SMALL && mario_immunity==0)
{mario_dead=1;finish_level=0;}
else
mario_smaller();
marioSmaller();
}
void move_ennemi(ennemi_t *e)
void ennemiMove(ennemi_t *e)
{
if (e->b.x<camera_x()+128+30 && e->b.x>camera_x()-30)
if (e->b.x<cameraX()+128+30 && e->b.x>cameraX()-30)
e->discovered=1;
//if (e->b.x+e->b.w<=world_get_real_x0())
//if (e->b.x+e->b.w<=worldGetCell_real_x0())
// e->type=NONE;
if (e->discovered==0)
return;
@ -99,12 +99,12 @@ void move_ennemi(ennemi_t *e)
if (e->type==NONE)
return;
bool e_hit_mario=ennemi_check_collision(e);
if (e_hit_mario&&mario_star_mode)
bool e_hitMario=ennemi_check_collision(e);
if (e_hitMario&&mario_starMode)
{
e->life=DEAD;
e->p1=0;
score_add(200);
scoreAdd(200);
return;
}
@ -114,7 +114,7 @@ void move_ennemi(ennemi_t *e)
if (t->type!=NONE)
{
e->b.x+=sgn(e->b.vx)*(abs(e->b.vx)+(time_id%2))/2;
const int contact=BoxContact(&e->b, &t->b);
const int contact=boxContact(&e->b, &t->b);
e->b.x-=sgn(e->b.vx)*(abs(e->b.vx)+(time_id%2))/2;
if (contact && t->life!=DEAD)
{
@ -134,7 +134,7 @@ void move_ennemi(ennemi_t *e)
{
t->life=DEAD;
t->p1=0;
score_add(200);
scoreAdd(200);
}
}
}
@ -146,12 +146,12 @@ void move_ennemi(ennemi_t *e)
if ((e->b.x+j)/8!=previous_case)
{
previous_case=(e->b.x+j)/8;
gift_t * c=(gift_t*)world_get(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;
score_add(100);
scoreAdd(100);
break;
}
}
@ -161,7 +161,7 @@ void move_ennemi(ennemi_t *e)
if (e->type==GOOMBA_ID)
{
box_move(&e->b);
boxMove(&e->b);
if (e->b.vx==0)
{
@ -178,25 +178,25 @@ void move_ennemi(ennemi_t *e)
}
if (e->b.y<0)
e->type=NONE;
if (e_hit_mario)
if (e_hitMario)
{
if (mario_fatal_hit)
{
e->life=DEAD;
e->p1=0;
score_add(200);
scoreAdd(200);
mario.p.vy=4;
mario.p.y=e->b.y+ennemi_heights[GOOMBA_ID]+1;
}
else
hurt_mario();
hurtMario();
}
return;
}
if (e->type==KOOPA_V_ID)
{
box_move(&e->b);
boxMove(&e->b);
if (e->b.vx==0)
{
if (e->p1==0)
@ -212,7 +212,7 @@ void move_ennemi(ennemi_t *e)
}
if (e->b.y<0)
e->type=NONE;
if (e_hit_mario)
if (e_hitMario)
{
if (mario_fatal_hit)
{
@ -220,19 +220,19 @@ void move_ennemi(ennemi_t *e)
e->b.h=ennemi_heights[CARAPACE_VERTE];
e->p1=2;
e->b.vx=0;
score_add(200);
scoreAdd(200);
mario.p.vy=4;
mario.p.y=e->b.y+ennemi_heights[CARAPACE_VERTE]+1;
}
else
hurt_mario();
hurtMario();
}
return;
}
if (e->type==KOOPA_R_ID)
{
box_move(&e->b);
boxMove(&e->b);
if (e->b.vx==0)
{
if (e->p1==0)
@ -252,7 +252,7 @@ void move_ennemi(ennemi_t *e)
if (e->b.vx>0)
s=e->b.w;
if (world_get_ctg(e->b.x+s, e->b.y-1)==CTG_EMPTY && sgn(e->b.vx)==sgn(s))
if (worldGetCellCategory(e->b.x+s, e->b.y-1)==CTG_EMPTY && sgn(e->b.vx)==sgn(s))
{
e->p1*=-1;
e->b.vx=e->p1;
@ -262,7 +262,7 @@ void move_ennemi(ennemi_t *e)
if (e->b.y<0)
e->type=NONE;
if (e_hit_mario)
if (e_hitMario)
{
if (mario_fatal_hit)
{
@ -270,12 +270,12 @@ void move_ennemi(ennemi_t *e)
e->b.h=ennemi_heights[CARAPACE_ROUGE];
e->p1=2;
e->b.vx=0;
score_add(200);
scoreAdd(200);
mario.p.vy=4;
mario.p.y=e->b.y+ennemi_heights[CARAPACE_ROUGE]+1;
}
else
hurt_mario();
hurtMario();
}
return;
}