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>
|
|
|
|
|
2020-01-08 16:16:05 +01:00
|
|
|
static int score=0;
|
2020-01-29 14:34:47 +01:00
|
|
|
static int lifes=3;
|
2019-11-30 13:57:18 +01:00
|
|
|
|
|
|
|
int combo=0;
|
|
|
|
int combo_id=-10;
|
|
|
|
|
|
|
|
int pieces=0;
|
|
|
|
|
|
|
|
int time_id=0;
|
|
|
|
int time_left=0;
|
2020-01-15 20:42:51 +01:00
|
|
|
int time_spent=0;
|
2019-11-30 13:57:18 +01:00
|
|
|
|
2020-01-11 15:19:53 +01:00
|
|
|
int finish_level=0;
|
2019-11-30 13:57:18 +01:00
|
|
|
|
2020-01-14 21:31:13 +01:00
|
|
|
void new_game()
|
2019-11-30 13:57:18 +01:00
|
|
|
{
|
|
|
|
|
2019-12-05 19:24:16 +01:00
|
|
|
lifes=3;
|
2019-11-30 13:57:18 +01:00
|
|
|
pieces=0;
|
|
|
|
score=0;
|
|
|
|
combo=0;
|
|
|
|
combo_id=-10;
|
2020-01-14 21:31:13 +01:00
|
|
|
mario_smaller();
|
2019-11-30 13:57:18 +01:00
|
|
|
new_level();
|
2020-01-15 20:42:51 +01:00
|
|
|
time_spent=0;
|
2019-11-30 13:57:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void new_level()
|
|
|
|
{
|
2020-01-11 15:19:53 +01:00
|
|
|
finish_level=0;
|
2019-12-11 16:31:18 +01:00
|
|
|
time_left=400;
|
2019-11-30 13:57:18 +01:00
|
|
|
time_id=0;
|
|
|
|
}
|
|
|
|
|
2020-01-08 16:16:05 +01:00
|
|
|
int get_score()
|
|
|
|
{
|
|
|
|
return score;
|
|
|
|
}
|
|
|
|
|
2020-01-25 11:54:39 +01:00
|
|
|
int get_coins()
|
|
|
|
{
|
|
|
|
return pieces;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-08 16:16:05 +01:00
|
|
|
void score_reset()
|
|
|
|
{
|
|
|
|
score=0;
|
|
|
|
combo=0;
|
|
|
|
combo_id=-10;
|
|
|
|
}
|
|
|
|
|
2019-11-30 13:57:18 +01:00
|
|
|
void score_add_coin()
|
|
|
|
{
|
|
|
|
pieces++;
|
|
|
|
}
|
|
|
|
|
|
|
|
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()
|
|
|
|
{
|
2020-01-06 18:43:36 +01:00
|
|
|
|
2019-11-30 13:57:18 +01:00
|
|
|
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++;
|
2019-12-11 16:31:18 +01:00
|
|
|
if (time_id%8==0)
|
2020-01-15 20:42:51 +01:00
|
|
|
{
|
2019-11-30 13:57:18 +01:00
|
|
|
time_left--;
|
2020-01-15 20:42:51 +01:00
|
|
|
time_spent++;
|
|
|
|
}
|
2019-11-30 13:57:18 +01:00
|
|
|
|
|
|
|
sprintf(str, "TIME : %d", time_left);
|
2020-01-15 20:42:51 +01:00
|
|
|
dtext(87-7,0,str, C_BLACK, C_WHITE);
|
2019-11-30 13:57:18 +01:00
|
|
|
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);
|
2020-01-06 18:43:36 +01:00
|
|
|
finish_level=0;
|
2020-01-11 15:19:53 +01:00
|
|
|
mario_dead=1;
|
2019-11-30 13:57:18 +01:00
|
|
|
}
|
2020-01-06 18:43:36 +01:00
|
|
|
}
|
2020-01-15 20:42:51 +01:00
|
|
|
|
|
|
|
int get_time_spent()
|
|
|
|
{
|
|
|
|
return time_spent;
|
2020-01-29 14:34:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int lifes_get()
|
|
|
|
{
|
|
|
|
return lifes;
|
|
|
|
}
|
|
|
|
|
|
|
|
void lifes_lose()
|
|
|
|
{
|
|
|
|
lifes --;
|
|
|
|
}
|
|
|
|
|
|
|
|
void lifes_add()
|
|
|
|
{
|
|
|
|
lifes ++;
|
2020-01-15 20:42:51 +01:00
|
|
|
}
|