improve time & score displaying

dev
Milang 3 years ago
parent 9760257d76
commit 76fe4d2e3f
  1. BIN
      INIT/CasioRAM.mem
  2. 4
      SuperCbr.dlw
  3. BIN
      SuperCbr.g1a
  4. 57
      src/score.c

Binary file not shown.

@ -2,7 +2,7 @@
[_1]
Type=5
Order=0
Order=1
Top=15
Left=2235
Height=4740
@ -13,7 +13,7 @@ OptionA=0
[_2]
Type=1
Order=1
Order=0
Top=15
Left=7800
Height=6885

Binary file not shown.

@ -6,6 +6,9 @@
#include <gint/clock.h>
#include <gint/timer.h>
// displaying time for volatile counters: here=1.5sec
#define DISPLAY_TIME 30
static int score=0;
static int lifes=3;
@ -69,8 +72,7 @@ void coinAdd()
void scoreAdd(int i)
{
if (i==0)
return;
if (i==0) return;
if (time_id-combo_id<=12 && combo)
{
score+=i;
@ -90,58 +92,49 @@ void scoreDisplay()
char str[10];
if (time_id-combo_id<=8 && combo) // displays score & combo only when there is a combo
if (time_id<=(unsigned int)(combo_id+DISPLAY_TIME) && time_id>=(unsigned int)(combo_id)) //displays score
{
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
if (time_id-combo_id<=8 && combo) // & combo only when there is a combo
{
combo=0;
sprintf(str, "+ %d", combo);
dtext(0,6,str, C_BLACK, C_WHITE);
}
else combo=0; // combo too old
if (time_last_piece<=time_id && time_id<=time_last_piece+30) // display pieces only when 1 is taken during 2 seconds
if (time_last_piece<=time_id && time_id<=time_last_piece+DISPLAY_TIME) // display pieces only when 1 is taken during 2 seconds
{
sprintf(str, "c*%d", pieces);
dtext(50,0,str, C_BLACK, C_WHITE);
}
if (mario_dead==0 && finish_level==0)
if ((mario_dead|finish_level)==0)
{
time_id++;
if (0==time_id%8)
if (0==(time_id++)%8)
{
time_left--;
time_spent++;
if (time_left==0)
{
extern image_t img_time_over;
dimage(0,0, &img_time_over); dupdate();
sleep_ms(3,3000);
finish_level=2;
return;
}
}
}
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 i=0; while (str[i]) i++;
dtext(128-6*i, 1, str, C_BLACK, C_WHITE);
}
int getTimeSpent()
{
return time_spent;
}
int getTimeSpent(void) { return time_spent; }
int lifesGet() { return lifes; }
int lifesGet(void) { return lifes; }
void lifesSet(int l) { lifes = l; }

Loading…
Cancel
Save