fix keyboard bug, lighten interface & clean some parts of the code
This commit is contained in:
parent
d9d6648a17
commit
e2b6eac34b
Binary file not shown.
|
@ -2,7 +2,7 @@
|
|||
|
||||
[_1]
|
||||
Type=5
|
||||
Order=3
|
||||
Order=0
|
||||
Top=15
|
||||
Left=2235
|
||||
Height=4740
|
||||
|
@ -25,7 +25,7 @@ OptionB=15
|
|||
|
||||
[_3]
|
||||
Type=6
|
||||
Order=0
|
||||
Order=2
|
||||
Top=4740
|
||||
Left=7800
|
||||
Height=6390
|
||||
|
@ -91,7 +91,7 @@ OptionA=0
|
|||
|
||||
[_9]
|
||||
Type=15
|
||||
Order=2
|
||||
Order=3
|
||||
Top=4740
|
||||
Left=2235
|
||||
Height=6345
|
||||
|
|
BIN
SuperCbr.g1a
BIN
SuperCbr.g1a
Binary file not shown.
|
@ -1,5 +1,5 @@
|
|||
#ifndef BASE_FUNCTIONS_H
|
||||
#define BASE_FUNCTIONS_H
|
||||
#define BASE_FUNCTIONS_H
|
||||
|
||||
// On va essayer de grapiller quelques octets d'executable avec ça
|
||||
|
||||
|
@ -9,8 +9,10 @@ int min(const int x, const int y);
|
|||
|
||||
int sgn(const int x);
|
||||
|
||||
int abs(const int x);
|
||||
|
||||
void* malloc_prof(int size);
|
||||
|
||||
void free_prof(void * p);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
// v0.3
|
||||
#ifndef MARIO_KEYBOARD_H
|
||||
#define MARIO_KEYBOARD_H
|
||||
#define MARIO_KEYBOARD_H
|
||||
|
||||
#define KONAMI
|
||||
|
||||
/* Reduced keyboard
|
||||
/* Reduced keyboard
|
||||
It simulates a nes controller */
|
||||
typedef enum
|
||||
{
|
||||
|
@ -12,9 +12,9 @@ typedef enum
|
|||
MK_LEFT=0,
|
||||
MK_RIGHT,
|
||||
MK_DOWN,
|
||||
MK_UP,
|
||||
MK_UP,
|
||||
MK_JUMP, // Shift
|
||||
MK_RUN // Alpha
|
||||
MK_RUN // Alpha
|
||||
} mkb_t;
|
||||
|
||||
/* This function has been coded to replace the following array
|
||||
|
@ -23,7 +23,7 @@ typedef enum
|
|||
2=newly pressed
|
||||
1=currently down
|
||||
0=up
|
||||
*/
|
||||
*/
|
||||
int mkb_getstate(mkb_t const k);
|
||||
|
||||
// Update the keyboard, should be called at each frame
|
||||
|
@ -36,4 +36,4 @@ void mkb_clear();
|
|||
// /!\ return gint keycodes
|
||||
int mkb_getkey();
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -8,15 +8,15 @@ void load_save(); // Ho calme toi pas tt de suite ! Utilisera BFile lorsque le h
|
|||
void flash_save(); // Non plus :E
|
||||
|
||||
int get_highscore(int world, int level);
|
||||
void set_highscore(int world, int level, int score);
|
||||
void set_highscore(int world, int level, unsigned int score);
|
||||
|
||||
int get_best_time(int world, int level);
|
||||
void set_best_time(int world, int level, int score);
|
||||
void set_best_time(int world, int level, unsigned int time);
|
||||
|
||||
int get_highcoins(int world, int level);
|
||||
void set_highcoins(int world, int level, int coins);
|
||||
void set_highcoins(int world, int level, unsigned int coins);
|
||||
|
||||
|
||||
int get_progress_status();
|
||||
unsigned int GetProgressStatus();
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
28
src/base.c
28
src/base.c
|
@ -14,15 +14,18 @@ int min(const int x, const int y)
|
|||
|
||||
int sgn(const int x)
|
||||
{
|
||||
if (x>0)
|
||||
return 1;
|
||||
else if (x<0)
|
||||
return -1;
|
||||
else
|
||||
return 0;
|
||||
if (x>0) return 1;
|
||||
else if (x<0) return -1;
|
||||
else return 0;
|
||||
}
|
||||
|
||||
static int ram_used=0;
|
||||
int abs(const int x)
|
||||
{
|
||||
if (x>0) return x;
|
||||
else return -x;
|
||||
}
|
||||
|
||||
static int ram_used=0;
|
||||
|
||||
void* malloc_prof(int size)
|
||||
{
|
||||
|
@ -32,13 +35,10 @@ void* malloc_prof(int size)
|
|||
ll_sendp(LEVEL_INFO, "\n[std] malloc %d OK", size);
|
||||
ram_used++;
|
||||
ll_sendp(LEVEL_INFO, "\n[std] number of zones %d", ram_used);
|
||||
return p;
|
||||
}
|
||||
if (p)
|
||||
{
|
||||
ll_sendp(LEVEL_CRITICAL, "\n[std] malloc %d FAILED", size);
|
||||
return p;
|
||||
}
|
||||
else ll_sendp(LEVEL_CRITICAL, "\n[std] malloc %d FAILED", size);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
void free_prof(void * p)
|
||||
|
@ -47,4 +47,4 @@ void free_prof(void * p)
|
|||
ll_sendp(LEVEL_INFO, "\n[std] free called");
|
||||
ram_used--;
|
||||
ll_sendp(LEVEL_INFO, "\n[std] number of zones %d", ram_used);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,14 +13,14 @@ static mkb_t keys[6]={0};
|
|||
int mkb_getstate(mkb_t const k)
|
||||
{
|
||||
if (k!=MK_NONE)
|
||||
return keys[k];
|
||||
return keys[k];
|
||||
return 0;
|
||||
}
|
||||
|
||||
void mkb_clear()
|
||||
{
|
||||
for (int i=0; i<6; i++)
|
||||
keys[i]=0;
|
||||
keys[i]=0;
|
||||
clearevents();
|
||||
}
|
||||
|
||||
|
@ -32,16 +32,16 @@ int mkb_getkey()
|
|||
{
|
||||
key_event_t const e=pollevent();
|
||||
if (e.key==KEY_ARROW)
|
||||
ll_pause();
|
||||
ll_pause();
|
||||
if (e.type==KEYEV_DOWN) // Returns only whan a key is down
|
||||
return e.key;
|
||||
return e.key;
|
||||
else
|
||||
sleep(); // Processor friendly :)
|
||||
sleep(); // Processor friendly :)
|
||||
}
|
||||
}
|
||||
|
||||
static int menu_pause() // 1 exit, 0 continue
|
||||
{
|
||||
{
|
||||
extern image_t img_menu_pause;
|
||||
extern image_t img_select_arrow;
|
||||
|
||||
|
@ -52,7 +52,7 @@ static int menu_pause() // 1 exit, 0 continue
|
|||
int x=64-img_menu_pause.width/2;
|
||||
int y=32-img_menu_pause.height/2;
|
||||
for (int i=0; i<6; i++)
|
||||
keys[i]=0;
|
||||
keys[i]=0;
|
||||
while (1)
|
||||
{
|
||||
dimage(x,y,&img_menu_pause);
|
||||
|
@ -70,19 +70,19 @@ static int menu_pause() // 1 exit, 0 continue
|
|||
// fall through
|
||||
case KEY_EXE:
|
||||
if (choice==2)
|
||||
configmenu();
|
||||
configmenu();
|
||||
return choice & 1;
|
||||
|
||||
case KEY_UP:
|
||||
if (choice>0)
|
||||
choice--;
|
||||
choice--;
|
||||
break;
|
||||
|
||||
case KEY_DOWN:
|
||||
if (choice<2)
|
||||
choice++;
|
||||
choice++;
|
||||
break;
|
||||
#ifdef KONAMI
|
||||
#ifdef KONAMI
|
||||
case KEY_F1:
|
||||
|
||||
for (int a=0; a<10; a++)
|
||||
|
@ -92,16 +92,16 @@ static int menu_pause() // 1 exit, 0 continue
|
|||
{
|
||||
static int const konami[]={KEY_UP,KEY_UP,KEY_DOWN,KEY_DOWN,KEY_LEFT,KEY_RIGHT,KEY_LEFT,KEY_RIGHT,KEY_ALPHA,KEY_SHIFT};
|
||||
if (e.key!=konami[a])
|
||||
break;
|
||||
break;
|
||||
}
|
||||
if (keydown(KEY_EXIT))
|
||||
break;
|
||||
break;
|
||||
if (a==10) // Cheat code
|
||||
{
|
||||
mario_bigger();
|
||||
mario_has_bullets=1;
|
||||
for (int i=0; i<20; i++)
|
||||
lifes_add();
|
||||
|
||||
LifesAdd(20);
|
||||
extern image_t img_dev;
|
||||
dimage(0,0,&img_dev);
|
||||
dupdate();
|
||||
|
@ -109,9 +109,9 @@ static int menu_pause() // 1 exit, 0 continue
|
|||
return 0;
|
||||
}
|
||||
else
|
||||
e=pollevent();
|
||||
e=pollevent();
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -121,33 +121,34 @@ void mkb_update()
|
|||
key_event_t e;
|
||||
e=pollevent();
|
||||
int menu=0, log=0;
|
||||
for (int i=0; i<6; i++)
|
||||
if (keys[i]==2) keys[i]=1;
|
||||
for (int i=0; i<6; i++) if (keys[i]==2) keys[i]=1; else if (keys[i]<0 || keys[i]>2) keys[i]=0;
|
||||
while(e.type!=KEYEV_NONE)
|
||||
{
|
||||
mkb_t k = MK_NONE;
|
||||
|
||||
if(e.key==KEY_LEFT)
|
||||
k=MK_LEFT;
|
||||
k=MK_LEFT;
|
||||
if(e.key==KEY_RIGHT)
|
||||
k=MK_RIGHT;
|
||||
k=MK_RIGHT;
|
||||
|
||||
if(e.key==KEY_SHIFT)
|
||||
k=MK_JUMP;
|
||||
k=MK_JUMP;
|
||||
if(e.key==KEY_COS)
|
||||
k=MK_JUMP;
|
||||
if(e.key==KEY_UP)
|
||||
k=MK_UP;
|
||||
k=MK_UP;
|
||||
|
||||
if(e.key==KEY_DOWN)
|
||||
k=MK_DOWN;
|
||||
k=MK_DOWN;
|
||||
|
||||
if(e.key==KEY_OPTN)
|
||||
k=MK_RUN;
|
||||
k=MK_RUN;
|
||||
|
||||
if(keydown(KEY_EXIT))
|
||||
menu=1; // Displays menu after updating the keyboard
|
||||
menu=1; // Displays menu after updating the keyboard
|
||||
|
||||
if (e.key==KEY_ARROW)
|
||||
log=1;
|
||||
log=1;
|
||||
|
||||
if (k!=MK_NONE)
|
||||
{
|
||||
|
@ -166,14 +167,9 @@ void mkb_update()
|
|||
{
|
||||
int t=menu_pause();
|
||||
if (t==1)
|
||||
finish_level=-1; // Exits the level
|
||||
finish_level=-1; // Exits the level
|
||||
return;
|
||||
}
|
||||
if (log)
|
||||
ll_pause();
|
||||
ll_pause();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -17,34 +17,26 @@
|
|||
#include <camera.h>
|
||||
#include <bonus.h>
|
||||
|
||||
int PlayLevel(int, int); // déclaration de la fonction codée plus bas
|
||||
|
||||
static void LevelChanger(int world)
|
||||
{
|
||||
int play_level(int, int); // déclaration de la fonction codée plus bas
|
||||
|
||||
extern image_t img_levelchanger;
|
||||
|
||||
mkb_clear(); // clear keyboard
|
||||
unsigned int choice=0;
|
||||
|
||||
// x y, first button coordinates and size
|
||||
const int xt = 19, yt = 7, wt = 6, ht = 6;
|
||||
|
||||
while (1)
|
||||
{
|
||||
mkb_clear();
|
||||
dimage(0,0,&img_levelchanger);
|
||||
|
||||
drect(xt+(2+wt)*choice, yt, xt+(wt+2)*choice+wt,yt+ht, C_INVERT);
|
||||
extern image_t img_levelchanger;
|
||||
dimage(0,0,&img_levelchanger); // Draw menu
|
||||
drect(19+8*choice, 7, 25+8*choice, 13, C_INVERT); // Invert color of selected level
|
||||
|
||||
char str[8];
|
||||
if (choice != 8)
|
||||
{
|
||||
sprintf(str, "%d", choice+1);
|
||||
dtext(45,19, str, C_BLACK, C_WHITE);
|
||||
}
|
||||
else
|
||||
{
|
||||
dtext(13,19, "MODE COURSE :", C_BLACK, C_WHITE);
|
||||
dtext(45,19, str, C_BLACK, C_WHITE); // Maybe later replace it by level names
|
||||
}
|
||||
else dtext(13,19, "MODE COURSE :", C_BLACK, C_WHITE);
|
||||
|
||||
if (get_best_time(world,choice))
|
||||
{
|
||||
|
@ -75,8 +67,6 @@ static void LevelChanger(int world)
|
|||
|
||||
dupdate();
|
||||
|
||||
|
||||
|
||||
//int key=getkey_opt(GETKEY_REP_ARROWS,0).key;
|
||||
switch (mkb_getkey())
|
||||
{
|
||||
|
@ -94,8 +84,7 @@ static void LevelChanger(int world)
|
|||
if (choice==8)
|
||||
{
|
||||
new_game();
|
||||
mario_smaller();
|
||||
mario_immunity=0;
|
||||
|
||||
for (int i=0; i<7; i+=0)
|
||||
{
|
||||
extern image_t img_new_level;
|
||||
|
@ -109,7 +98,7 @@ static void LevelChanger(int world)
|
|||
dupdate();
|
||||
sleep_ms(3,2000);
|
||||
|
||||
int a=play_level(world, i);
|
||||
int a=PlayLevel(world, i);
|
||||
if (a==0) LifesAdd(-1);
|
||||
if (a==1) i++;
|
||||
if (a==-1) break;
|
||||
|
@ -140,7 +129,7 @@ static void LevelChanger(int world)
|
|||
|
||||
playagain:
|
||||
new_game();
|
||||
switch (play_level(world, choice))
|
||||
switch (PlayLevel(world, choice))
|
||||
{
|
||||
case 1: // if level completed
|
||||
set_best_time(world, choice, get_time_spent());
|
||||
|
@ -188,7 +177,7 @@ void LaunchUI() // Main Menu
|
|||
//Show unlocked worlds
|
||||
|
||||
extern image_t img_w1, img_w2, img_w3, img_w4, img_w5;
|
||||
switch (get_progress_status())
|
||||
switch (GetProgressStatus())
|
||||
{
|
||||
case 4:
|
||||
dimage(xt, yt+24, &img_w5);
|
||||
|
@ -250,7 +239,7 @@ void LaunchUI() // Main Menu
|
|||
return;
|
||||
|
||||
default:
|
||||
if (4*choice_y+choice_x<=get_progress_status())
|
||||
if (4*choice_y+choice_x<=GetProgressStatus())
|
||||
LevelChanger(4*choice_y+choice_x);
|
||||
}
|
||||
break;
|
||||
|
@ -268,7 +257,7 @@ void LaunchUI() // Main Menu
|
|||
|
||||
int frame_id;
|
||||
|
||||
int play_level(int w, int l)
|
||||
int PlayLevel(int w, int l)
|
||||
{
|
||||
init_refresh();
|
||||
|
||||
|
|
137
src/mario.c
137
src/mario.c
|
@ -8,16 +8,7 @@
|
|||
#include "bonus.h"
|
||||
#include <bullets.h>
|
||||
#include <camera.h>
|
||||
|
||||
static int sgn(int x)
|
||||
{
|
||||
if (x>0)
|
||||
return 1;
|
||||
else if (x<0)
|
||||
return -1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
#include <base.h>
|
||||
|
||||
int id_frame=0;
|
||||
|
||||
|
@ -53,7 +44,7 @@ void mario_smaller()
|
|||
mario.size=M_SMALL;
|
||||
mario_has_bullets=0;
|
||||
if (mario_immunity==0)
|
||||
mario_immunity=1;
|
||||
mario_immunity=1;
|
||||
//mario.p.vy=5;
|
||||
}
|
||||
|
||||
|
@ -63,21 +54,18 @@ void mario_draw()
|
|||
{
|
||||
if (mario.size==M_SMALL)
|
||||
{
|
||||
if (mario.p.vx*sgn(mario.p.vx)>=3)
|
||||
draw_tile(mario.p.x-camera_x(mario.p.x), mario.p.y-camera_y(mario.p.y), &mario_small, 2*last_vx_sign+(id_frame/4)%2, 0);
|
||||
else if (mario.p.vx*sgn(mario.p.vx)>=1)
|
||||
draw_tile(mario.p.x-camera_x(mario.p.x), mario.p.y-camera_y(mario.p.y), &mario_small, 2*last_vx_sign+(id_frame/8)%2, 0);
|
||||
else
|
||||
draw_tile(mario.p.x-camera_x(mario.p.x), mario.p.y-camera_y(mario.p.y), &mario_small, 2*last_vx_sign, 0);
|
||||
if (mario.p.vx*sgn(mario.p.vx)>=3) draw_tile(mario.p.x-camera_x(mario.p.x), mario.p.y-camera_y(mario.p.y), &mario_small, 2*last_vx_sign+(id_frame/4)%2, 0);
|
||||
else if (mario.p.vx*sgn(mario.p.vx)>=1) draw_tile(mario.p.x-camera_x(mario.p.x), mario.p.y-camera_y(mario.p.y), &mario_small, 2*last_vx_sign+(id_frame/8)%2, 0);
|
||||
else draw_tile(mario.p.x-camera_x(mario.p.x), mario.p.y-camera_y(mario.p.y), &mario_small, 2*last_vx_sign, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mario.p.vx*sgn(mario.p.vx)>=3)
|
||||
draw_tile(mario.p.x-camera_x(mario.p.x), mario.p.y-camera_y(mario.p.y), &mario_big, 4*last_vx_sign+(id_frame/4)%2, mario_has_bullets);
|
||||
draw_tile(mario.p.x-camera_x(mario.p.x), mario.p.y-camera_y(mario.p.y), &mario_big, 4*last_vx_sign+(id_frame/4)%2, mario_has_bullets);
|
||||
else if (mario.p.vx*sgn(mario.p.vx)>=1)
|
||||
draw_tile(mario.p.x-camera_x(mario.p.x), mario.p.y-camera_y(mario.p.y), &mario_big, 4*last_vx_sign+(id_frame/8)%2, mario_has_bullets);
|
||||
draw_tile(mario.p.x-camera_x(mario.p.x), mario.p.y-camera_y(mario.p.y), &mario_big, 4*last_vx_sign+(id_frame/8)%2, mario_has_bullets);
|
||||
else
|
||||
draw_tile(mario.p.x-camera_x(mario.p.x), mario.p.y-camera_y(mario.p.y), &mario_big, 3*last_vx_sign, mario_has_bullets);
|
||||
draw_tile(mario.p.x-camera_x(mario.p.x), mario.p.y-camera_y(mario.p.y), &mario_big, 3*last_vx_sign, mario_has_bullets);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -90,14 +78,14 @@ int test_sol_le_plus_proche(int x, int y)
|
|||
{
|
||||
int type_sol = world_get_ctg(x, y-1);
|
||||
if (type_sol==CTG_SOIL)
|
||||
t=1;
|
||||
t=1;
|
||||
if (type_sol==CTG_DEATH)
|
||||
return distance+1;
|
||||
return distance+1;
|
||||
type_sol = world_get_ctg(x+7, y-1);
|
||||
if (type_sol==CTG_SOIL)
|
||||
t=1;
|
||||
t=1;
|
||||
if (type_sol==CTG_DEATH)
|
||||
return distance+1;
|
||||
return distance+1;
|
||||
y--;
|
||||
distance++;
|
||||
}
|
||||
|
@ -113,43 +101,36 @@ void mario_move()
|
|||
{
|
||||
mario_star_mode++;
|
||||
if (mario_star_mode==200)
|
||||
mario_star_mode=0;
|
||||
mario_star_mode=0;
|
||||
}
|
||||
if (mario_immunity)
|
||||
{
|
||||
mario_immunity++;
|
||||
if (mario_immunity==60)
|
||||
mario_immunity=0;
|
||||
mario_immunity=0;
|
||||
}
|
||||
|
||||
id_frame++;
|
||||
if (mario_has_bullets==1 && mkb_getstate(MK_RUN)==2)
|
||||
{
|
||||
bullet_throw();
|
||||
}
|
||||
if (mario_has_bullets==1 && mkb_getstate(MK_RUN)==2) bullet_throw();
|
||||
|
||||
static int jump_buffering=0;
|
||||
static int coyote_time=0;
|
||||
if (mkb_getstate(MK_JUMP)==2 || jump_buffering) //|| keys[MK_JUMP2]==2)
|
||||
{
|
||||
|
||||
if (mario.p.vx*sgn(mario.p.vx)>=6)
|
||||
box_jump(&mario.p, 9);
|
||||
else
|
||||
box_jump(&mario.p, 8);
|
||||
if (mario.p.vx*sgn(mario.p.vx)>=6) box_jump(&mario.p, 9);
|
||||
else box_jump(&mario.p, 8);
|
||||
|
||||
if (mario.p.vy<=0 && mkb_getstate(MK_JUMP)==2 && coyote_time<4) // n'a pas sauté alors que la touche était enfoncée et coyote time
|
||||
{
|
||||
if (mario.p.vx*sgn(mario.p.vx)>=6)
|
||||
mario.p.vy=9;
|
||||
else
|
||||
mario.p.vy=8;
|
||||
if (mario.p.vx*sgn(mario.p.vx)>=6) mario.p.vy=9;
|
||||
else mario.p.vy=8;
|
||||
}
|
||||
else if (mario.p.vy<=0 && mkb_getstate(MK_JUMP)==2) // n'a pas sauté alors que la touche était enfoncée
|
||||
jump_buffering=5;
|
||||
jump_buffering=5;
|
||||
}
|
||||
if (jump_buffering)
|
||||
jump_buffering--;
|
||||
jump_buffering--;
|
||||
|
||||
for (int i=0; i<mario.p.w; i++)
|
||||
{
|
||||
|
@ -162,70 +143,32 @@ void mario_move()
|
|||
coyote_time++;
|
||||
|
||||
if (mario.p.vy>=2 && mkb_getstate(MK_JUMP)==0)
|
||||
mario.p.vy--;
|
||||
mario.p.vy-=2;
|
||||
|
||||
int vx=sgn(mkb_getstate(MK_RIGHT) - mkb_getstate(MK_LEFT));
|
||||
|
||||
int c1=world_get_ctg(mario.p.x, mario.p.y-1/*+mario.p.h*/);
|
||||
int c2=world_get_ctg(mario.p.x+mario.p.w-1, mario.p.y-1/*+mario.p.h*/);
|
||||
|
||||
if (vx)
|
||||
mario_time_accel=1-mario_time_accel;
|
||||
if (vx==-sgn(mario.p.vx)) mario_time_accel=1;
|
||||
if (mario_time_accel)
|
||||
{
|
||||
if (vx==sgn(mario.p.vx) || vx==0)
|
||||
mario_time_accel++;
|
||||
else if (vx==-sgn(mario.p.vx))
|
||||
mario_time_accel=0;
|
||||
|
||||
mario_time_accel%=2;
|
||||
if (mario_time_accel==0)
|
||||
if (vx)
|
||||
{
|
||||
if (mkb_getstate(MK_RUN) && (c1==CTG_SOIL || c2==CTG_SOIL))
|
||||
{
|
||||
if(mario.p.vx*vx<=8)
|
||||
mario.p.vx+=vx;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mario.p.vx*vx<4)
|
||||
mario.p.vx+=vx;
|
||||
|
||||
}
|
||||
if (mkb_getstate(MK_RUN)==0)
|
||||
{
|
||||
if (mario.p.vx*vx>4)
|
||||
mario.p.vx-=vx;
|
||||
}
|
||||
// sprinte et est sur le sol
|
||||
if (mkb_getstate(MK_RUN) && (c1==CTG_SOIL || c2==CTG_SOIL) && (abs(mario.p.vx)<=7 || sgn(mario.p.vx)!=vx)) mario.p.vx+=vx;
|
||||
else if (abs(mario.p.vx+vx) <= 4) mario.p.vx+=vx;
|
||||
// ralentissement si au dela de la vitesse sans sprint
|
||||
else if (mkb_getstate(MK_RUN)==0 && abs(mario.p.vx)>4) mario.p.vx-=sgn(mario.p.vx);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mario.p.vx)
|
||||
{
|
||||
if (mario_accel)
|
||||
{
|
||||
mario_time_accel++;
|
||||
mario_time_accel%=4;
|
||||
if (mario_time_accel==0)
|
||||
{
|
||||
mario.p.vx-=sgn(mario.p.vx);
|
||||
mario_accel=-sgn(mario.p.vx);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mario.p.vx-=sgn(mario.p.vx);
|
||||
mario_accel=-sgn(mario.p.vx);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
mario_time_accel=0;
|
||||
else mario.p.vx-=sgn(mario.p.vx);
|
||||
}
|
||||
|
||||
if (vx>0 && (c1==CTG_SOIL || c2==CTG_SOIL))
|
||||
last_vx_sign=1;
|
||||
last_vx_sign=1;
|
||||
if (vx<0 && (c1==CTG_SOIL || c2==CTG_SOIL))
|
||||
last_vx_sign=0;
|
||||
last_vx_sign=0;
|
||||
|
||||
if (mario.p.x+mario.p.vx<camera_x(mario.p.x))
|
||||
{
|
||||
|
@ -236,24 +179,24 @@ void mario_move()
|
|||
box_move(&mario.p); // <-> + gravity
|
||||
|
||||
if (mario.p.y<0)
|
||||
mario_dead=1;
|
||||
mario_dead=1;
|
||||
if (mario.p.vx==0)
|
||||
mario_time_accel=0;
|
||||
mario_time_accel=0;
|
||||
|
||||
// coins
|
||||
coin_t* c;
|
||||
c=(coin_t*)world_get(mario.p.x, mario.p.y);
|
||||
if (c->type==COIN && c->taken==0)
|
||||
{score_add_coin();c->taken=1;}
|
||||
{score_add_coin();c->taken=1;}
|
||||
c=(coin_t*)world_get(mario.p.x+mario.p.w-1, mario.p.y);
|
||||
if (c->type==COIN && c->taken==0)
|
||||
{score_add_coin();c->taken=1;}
|
||||
{score_add_coin();c->taken=1;}
|
||||
c=(coin_t*)world_get(mario.p.x, mario.p.y+mario.p.h-1);
|
||||
if (c->type==COIN && c->taken==0)
|
||||
{score_add_coin();c->taken=1;}
|
||||
{score_add_coin();c->taken=1;}
|
||||
c=(coin_t*)world_get(mario.p.x+mario.p.w-1, mario.p.y+mario.p.h-1);
|
||||
if (c->type==COIN && c->taken==0)
|
||||
{score_add_coin();c->taken=1;}
|
||||
{score_add_coin();c->taken=1;}
|
||||
|
||||
end_level_t *e1=(end_level_t*)world_get(mario.p.x, mario.p.y), *e2=(end_level_t*)world_get(mario.p.x+mario.p.w-1, mario.p.y);
|
||||
if (e1->type==END_LEVEL)
|
||||
|
|
14
src/save.c
14
src/save.c
|
@ -24,7 +24,7 @@ int get_highscore(int world, int level)
|
|||
return level_scores[world%NB_MONDES][level%WORLD_RUN_ENTRY];
|
||||
}
|
||||
|
||||
void set_highscore(int world, int level, int score)
|
||||
void set_highscore(int world, int level, unsigned int score)
|
||||
{
|
||||
if (score>level_scores[world%NB_MONDES][level%WORLD_RUN_ENTRY])
|
||||
level_scores[world%NB_MONDES][level%WORLD_RUN_ENTRY]=score;
|
||||
|
@ -36,7 +36,7 @@ int get_highcoins(int world, int level)
|
|||
return level_coins[world%NB_MONDES][level%WORLD_RUN_ENTRY];
|
||||
}
|
||||
|
||||
void set_highcoins(int world, int level, int coins)
|
||||
void set_highcoins(int world, int level, unsigned int coins)
|
||||
{
|
||||
if (coins>level_coins[world%NB_MONDES][level%WORLD_RUN_ENTRY])
|
||||
level_coins[world%NB_MONDES][level%WORLD_RUN_ENTRY]=coins;
|
||||
|
@ -48,13 +48,13 @@ int get_best_time(int world, int level)
|
|||
return level_times[world%NB_MONDES][level%WORLD_RUN_ENTRY];
|
||||
}
|
||||
|
||||
void set_best_time(int world, int level, int score)
|
||||
void set_best_time(int world, int level, unsigned int time)
|
||||
{
|
||||
if (level_times[world%NB_MONDES][level%WORLD_RUN_ENTRY]==0 || score<level_times[world%NB_MONDES][level%WORLD_RUN_ENTRY])
|
||||
level_times[world%NB_MONDES][level%WORLD_RUN_ENTRY]=score;
|
||||
if (level_times[world%NB_MONDES][level%WORLD_RUN_ENTRY]==0 || time<level_times[world%NB_MONDES][level%WORLD_RUN_ENTRY])
|
||||
level_times[world%NB_MONDES][level%WORLD_RUN_ENTRY]=time;
|
||||
}
|
||||
|
||||
int get_progress_status()
|
||||
unsigned int GetProgressStatus()
|
||||
{
|
||||
return progress_status;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -213,6 +213,10 @@ void world_draw()
|
|||
}
|
||||
//teleporteurs_display();
|
||||
//dvline(teleporteurs[0].x-world_get_real_x0(),C_BLACK);
|
||||
|
||||
if (mkb_getstate(MK_JUMP)) drect(1,60,6,63,C_BLACK);
|
||||
if (mkb_getstate(MK_RUN)) drect(8,60,13,63,C_BLACK);
|
||||
|
||||
}
|
||||
|
||||
void world_move()
|
||||
|
@ -227,7 +231,7 @@ void world_move()
|
|||
move_plateformes();
|
||||
mario_move();
|
||||
teleport_active();
|
||||
|
||||
|
||||
}
|
||||
|
||||
void world_set(int w, int h, int x, int y, cell_t const * a)
|
||||
|
@ -258,4 +262,4 @@ void world_set(int w, int h, int x, int y, cell_t const * a)
|
|||
mario.p.x = map_current->start_x = x;
|
||||
mario.p.y = map_current->start_y = y;
|
||||
memcpy(map_current->data, a, sizeof(cell_t)*w*h);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue