add coins saving

This commit is contained in:
Milang 2020-01-25 11:54:39 +01:00
parent dbf5416ba7
commit ef4d0ffcdf
14 changed files with 513 additions and 478 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -13,6 +13,10 @@ void set_highscore(int world, int level, int score);
int get_best_time(int world, int level);
void set_best_time(int world, int level, int score);
int get_highcoins(int world, int level);
void set_highcoins(int world, int level, int coins);
int get_progress_status();
#endif

View File

@ -7,6 +7,7 @@ extern int finish_level; // si ==-1, continue, si 0==retry, si ==1 ou + next
extern int time_id;
int get_score();
int get_coins();
void score_reset();
void score_add(int);
void score_display();

View File

@ -59,6 +59,13 @@ static void levelchanger(int w)
i++;
dtext(99-6*i, 45, str, C_BLACK, C_WHITE);
sprintf(str, "%d", get_highcoins(w,choice));
i=0;
while (str[i])
i++;
dtext(90-6*i, 37, str, C_BLACK, C_WHITE);
dupdate();
@ -102,18 +109,21 @@ static void levelchanger(int w)
}
else
{
dienretry:
new_game();
mario_smaller();
mario_immunity=0;
int s=play_level(w, choice);
if (s==1)
while (1)
{
set_best_time(w, choice, get_time_spent());
new_game();
mario_smaller();
mario_immunity=0;
int s=play_level(w, choice);
if (s==1)
{
set_best_time(w, choice, get_time_spent());
}
set_highscore(w, choice, get_score());
set_highcoins(w, choice, get_coins());
if (s)
break;
}
set_highscore(w, choice, get_score());
if (s==0)
goto dienretry;
}
}

View File

@ -30,6 +30,19 @@ void set_highscore(int world, int level, int score)
level_scores[world%NB_MONDES][level%WORLD_RUN_ENTRY]=score;
}
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)
{
if (coins>level_coins[world%NB_MONDES][level%WORLD_RUN_ENTRY])
level_coins[world%NB_MONDES][level%WORLD_RUN_ENTRY]=coins;
}
int get_best_time(int world, int level)
{
return level_times[world%NB_MONDES][level%WORLD_RUN_ENTRY];

View File

@ -45,6 +45,12 @@ int get_score()
return score;
}
int get_coins()
{
return pieces;
}
void score_reset()
{
score=0;

View File

@ -36,9 +36,8 @@ void teleport_active()
if (!keys[t.key])
continue;
}
mario.p.x=t.tx*8;
mario.p.y=t.ty*8;
mario.p.vx=mario.p.vy=0;
mario.p.x=t.tx*8; mario.p.y=t.ty*8;
mario.p.vx=0; mario.p.vy=0;
}
}
}