Le nouveau Super Mario Bros pour la gamme des fx9860g https://www.planet-casio.com/Fr/forums/topic15994-1-[addin]-SuperCasioBros-v0.1.html
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
supercasiobros/src/score.c

145 lines
2.0 KiB

#include "score.h"
#include "mario.h"
#include <gint/display.h>
#include <gint/std/stdio.h>
#include <gint/clock.h>
#include <gint/timer.h>
static int score=0;
static int lifes=3;
int combo=0;
int combo_id=-10;
static int pieces=0;
static unsigned int time_last_piece=0;
int time_id=0;
int time_left=0;
int time_spent=0;
int finish_level=0;
void new_game()
{
lifes=3;
pieces=0;
score=0;
combo=0;
combo_id=-10;
mario_smaller();
mario_immunity=0;
new_level();
time_spent=0;
}
void new_level()
{
finish_level=0;
time_left=400;
time_id=0;
}
int get_score()
{
return score;
}
int get_coins()
{
return pieces;
}
void score_reset()
{
score=0;
combo=0;
combo_id=-10;
}
void score_add_coin()
{
pieces++;
time_last_piece=time_id;
score_add(200);
}
void score_add(int i)
{
if (i==0)
return;
if (time_id-combo_id<=12 && time_id-combo_id>=0 && combo)
{
score+=i;
combo_id=time_id;
combo+=i;
}
else
{
combo_id=time_id;
combo=i;
score+=i;
}
}
void score_display()
{
char str[10];
if (time_id-combo_id<=8 && time_id-combo_id>=0 && combo) // displays score & combo only when there is a combo
{
sprintf(str, "%d", score);
dtext(0,0,str, C_BLACK, C_WHITE);
sprintf(str, "+ %d", combo);
dtext(0,6,str, C_BLACK, C_WHITE);
}
else
{
combo=0;
}
if (time_last_piece<=time_id && time_id<=time_last_piece+30) // display pieces only when 1 is taken during 2 seconds
{
sprintf(str, "c*%d", pieces);
dtext(50,0,str, C_BLACK, C_WHITE);
}
time_id++;
if (time_id%8==0)
{
time_left--;
time_spent++;
}
sprintf(str, "%d", time_left);
int i=0;
while (str[i]) i++;
dtext(127-6*i, 1, str, C_BLACK, C_WHITE);
extern image_t img_time_over;
if (time_left==0)
{
dimage(0,0, &img_time_over);
dupdate();
sleep_ms(3,1000);
sleep_ms(3,1000);
sleep_ms(3,1000);
finish_level=2;
}
}
int get_time_spent()
{
return time_spent;
}
int LifesGet() { return lifes; }
void LifesSet(int l) { lifes = l; }
void LifesAdd(int l) { lifes += l; }