2019-11-30 13:57:18 +01:00
|
|
|
#include "score.h"
|
|
|
|
#include "mario.h"
|
|
|
|
|
|
|
|
#include <gint/display.h>
|
|
|
|
#include <gint/std/stdio.h>
|
|
|
|
#include <gint/clock.h>
|
|
|
|
#include <gint/timer.h>
|
|
|
|
|
|
|
|
int score=0;
|
|
|
|
int lifes=5;
|
|
|
|
|
|
|
|
int combo=0;
|
|
|
|
int combo_id=-10;
|
|
|
|
|
|
|
|
int pieces=0;
|
|
|
|
|
|
|
|
int time_id=0;
|
|
|
|
int time_left=0;
|
|
|
|
|
|
|
|
int end_level=-1;
|
|
|
|
|
|
|
|
void new_game()
|
|
|
|
{
|
|
|
|
|
|
|
|
lifes=5;
|
|
|
|
pieces=0;
|
|
|
|
score=0;
|
|
|
|
combo=0;
|
|
|
|
combo_id=-10;
|
|
|
|
new_level();
|
|
|
|
}
|
|
|
|
|
|
|
|
void new_level()
|
|
|
|
{
|
|
|
|
end_level=-1;
|
|
|
|
time_left=300;
|
|
|
|
time_id=0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void score_add_coin()
|
|
|
|
{
|
|
|
|
pieces++;
|
|
|
|
score_add(10);
|
|
|
|
}
|
|
|
|
|
|
|
|
void score_add(int i)
|
|
|
|
{
|
|
|
|
if (i==0)
|
|
|
|
return;
|
|
|
|
if (time_id-combo_id<=12 && time_id-combo_id>=0 && combo)
|
|
|
|
{
|
|
|
|
i*=2;
|
|
|
|
score+=i;
|
|
|
|
combo_id=time_id;
|
|
|
|
combo+=i;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
combo_id=time_id;
|
|
|
|
combo=i;
|
|
|
|
score+=i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void score_display()
|
|
|
|
{
|
|
|
|
|
|
|
|
char str[10];
|
|
|
|
sprintf(str, "%d", score);
|
|
|
|
dtext(0,0,str, C_BLACK, C_WHITE);
|
|
|
|
if (time_id-combo_id<=8 && time_id-combo_id>=0 && combo)
|
|
|
|
{
|
|
|
|
sprintf(str, "+ %d", combo);
|
|
|
|
dtext(0,6,str, C_BLACK, C_WHITE);
|
|
|
|
}
|
2019-12-03 19:53:30 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
combo=0;
|
|
|
|
}
|
2019-11-30 13:57:18 +01:00
|
|
|
sprintf(str, "c*%d", pieces);
|
|
|
|
dtext(50,0,str, C_BLACK, C_WHITE);
|
|
|
|
|
|
|
|
time_id++;
|
|
|
|
if (time_id%10==0)
|
|
|
|
time_left--;
|
|
|
|
|
|
|
|
sprintf(str, "TIME : %d", time_left);
|
|
|
|
dtext(87,0,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);
|
|
|
|
end_level=0;
|
|
|
|
}
|
|
|
|
}
|