clean ingame interface -> score & coins are hidden, and are shown only when they change

dev
Milang 3 years ago
parent 8ab8a4cd7a
commit d9d6648a17
  1. BIN
      INIT/CasioRAM.mem
  2. BIN
      INIT/CasioRAMCPU.mem
  3. 77
      SuperCbr.c
  4. 1
      SuperCbr.dlr
  5. 22
      SuperCbr.dlw
  6. BIN
      SuperCbr.g1a
  7. 3
      SuperCbr.g1w
  8. 152
      src/levelchanger.c
  9. 28
      src/score.c

Binary file not shown.

Binary file not shown.

@ -1,77 +0,0 @@
/*****************************************************************/
/* */
/* CASIO fx-9860G SDK Library */
/* */
/* File name : [ProjectName].c */
/* */
/* Copyright (c) 2006 CASIO COMPUTER CO., LTD. */
/* */
/*****************************************************************/
#include "fxlib.h"
//****************************************************************************
// AddIn_main (Sample program main function)
//
// param : isAppli : 1 = This application is launched by MAIN MENU.
// : 0 = This application is launched by a strip in eACT application.
//
// OptionNum : Strip number (0~3)
// (This parameter is only used when isAppli parameter is 0.)
//
// retval : 1 = No error / 0 = Error
//
//****************************************************************************
int AddIn_main(int isAppli, unsigned short OptionNum)
{
unsigned int key;
Bdisp_AllClr_DDVRAM();
locate(1,4);
Print((unsigned char*)"This application is");
locate(1,5);
Print((unsigned char*)" sample Add-In.");
while(1){
GetKey(&key);
}
return 1;
}
//****************************************************************************
//************** ****************
//************** Notice! ****************
//************** ****************
//************** Please do not change the following source. ****************
//************** ****************
//****************************************************************************
#pragma section _BR_Size
unsigned long BR_Size;
#pragma section
#pragma section _TOP
//****************************************************************************
// InitializeSystem
//
// param : isAppli : 1 = Application / 0 = eActivity
// OptionNum : Option Number (only eActivity)
//
// retval : 1 = No error / 0 = Error
//
//****************************************************************************
int InitializeSystem(int isAppli, unsigned short OptionNum)
{
return INIT_ADDIN_APPLICATION(isAppli, OptionNum);
}
#pragma section

@ -0,0 +1 @@
[DLSimRunSpace]

@ -2,7 +2,7 @@
[_1]
Type=5
Order=5
Order=3
Top=15
Left=2235
Height=4740
@ -13,7 +13,7 @@ OptionA=0
[_2]
Type=1
Order=4
Order=1
Top=15
Left=7800
Height=4740
@ -25,7 +25,7 @@ OptionB=15
[_3]
Type=6
Order=2
Order=0
Top=4740
Left=7800
Height=6390
@ -36,7 +36,7 @@ OptionA=0
[_4]
Type=7
Order=1
Order=6
Top=4740
Left=2220
Height=3165
@ -47,7 +47,7 @@ OptionA=0
[_5]
Type=8
Order=0
Order=5
Top=7905
Left=2220
Height=3225
@ -80,7 +80,7 @@ OptionA=0
[_8]
Type=17
Order=3
Order=4
Top=15
Left=-15
Height=11115
@ -91,12 +91,12 @@ OptionA=0
[_9]
Type=15
Order=6
Order=2
Top=4740
Left=2232
Height=6348
Width=5592
State=16
Left=2235
Height=6345
Width=5595
State=0
Flags=00000000
OptionA=0

Binary file not shown.

@ -10,6 +10,3 @@ MemCardPath=SDCard
Program=SUPERCBR.G1A
Debug=Debug\FXADDINror.dbg
LoadAddress=80000000:90100000
[Files]
SourceFile=:SuperCbr.c

@ -17,13 +17,13 @@
#include <camera.h>
#include <bonus.h>
static void levelchanger(int w)
static void LevelChanger(int world)
{
int play_level(int w, int l); // déclaration de la fonction codée plus bas
int play_level(int, int); // déclaration de la fonction codée plus bas
extern image_t img_levelchanger;
int choice=0;
extern image_t img_levelchanger;
unsigned int choice=0;
// x y, first button coordinates and size
const int xt = 19, yt = 7, wt = 6, ht = 6;
@ -37,7 +37,7 @@ static void levelchanger(int w)
char str[8];
if (choice != 8)
{
{
sprintf(str, "%d", choice+1);
dtext(45,19, str, C_BLACK, C_WHITE);
}
@ -46,43 +46,51 @@ static void levelchanger(int w)
dtext(13,19, "MODE COURSE :", C_BLACK, C_WHITE);
}
if (get_best_time(w,choice))
if (get_best_time(world,choice))
{
sprintf(str, "%d", get_best_time(w,choice));
sprintf(str, "%d", get_best_time(world,choice));
int i=0;
while (str[i])
i++;
i++;
dtext(99-6*i, 53, str, C_BLACK, C_WHITE);
}
sprintf(str, "%d", get_highscore(w,choice));
int i=0;
while (str[i])
if (get_highscore(world,choice))
{
sprintf(str, "%d", get_highscore(world,choice));
int i=0;
while (str[i])
i++;
dtext(99-6*i, 45, str, C_BLACK, C_WHITE);
dtext(99-6*i, 45, str, C_BLACK, C_WHITE);
}
sprintf(str, "%d", get_highcoins(w,choice));
i=0;
while (str[i])
if (get_highcoins(world,choice))
{
sprintf(str, "%d", get_highcoins(world,choice));
int i=0;
while (str[i])
i++;
dtext(90-6*i, 37, str, C_BLACK, C_WHITE);
dtext(90-6*i, 37, str, C_BLACK, C_WHITE);
}
dupdate();
//int key=getkey_opt(GETKEY_REP_ARROWS,0).key;
int key=mkb_getkey();
if (key==KEY_LEFT && choice>0)
choice--;
if (key==KEY_RIGHT && choice<8)
choice++;
if (key==KEY_EXE || key==KEY_SHIFT)
//int key=getkey_opt(GETKEY_REP_ARROWS,0).key;
switch (mkb_getkey())
{
case KEY_LEFT:
if (choice) /* >0 */ choice--;
break;
case KEY_RIGHT:
if (choice!=8) /* <8 */ choice++;
break;
case KEY_EXE:
// fall through
case KEY_SHIFT:
if (choice==8)
{
new_game();
@ -93,7 +101,7 @@ static void levelchanger(int w)
extern image_t img_new_level;
dimage(0,0,&img_new_level);
char lvl[4];
get_lvl_id(w, i, lvl);
get_lvl_id(world, i, lvl);
dtext(53,28, lvl, C_WHITE, C_BLACK);
sprintf(lvl, "%d", LifesGet());
@ -101,13 +109,10 @@ static void levelchanger(int w)
dupdate();
sleep_ms(3,2000);
int a=play_level(w, i);
if (a==0)
LifesAdd(-1);
if (a==1)
i++;
if (a==-1)
break;
int a=play_level(world, i);
if (a==0) LifesAdd(-1);
if (a==1) i++;
if (a==-1) break;
if (LifesGet()==0)
{
extern image_t img_game_over;
@ -118,14 +123,14 @@ static void levelchanger(int w)
break;
}
}
set_highscore(w, choice, get_score());
set_highscore(world, choice, get_score());
}
else
{
extern image_t img_new_level;
dimage(0,0,&img_new_level);
char lvl[4];
get_lvl_id(w, choice, lvl);
get_lvl_id(world, choice, lvl);
dtext(53,28, lvl, C_WHITE, C_BLACK);
sprintf(lvl, "%d", LifesGet());
@ -133,35 +138,42 @@ static void levelchanger(int w)
dupdate();
sleep_ms(3,2000);
while (1)
playagain:
new_game();
switch (play_level(world, choice))
{
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;
case 1: // if level completed
set_best_time(world, choice, get_time_spent());
set_highscore(world, choice, get_score());
set_highcoins(world, choice, get_coins());
break; // go back to menu
case 0: // save score anyways
set_highscore(world, choice, get_score());
set_highcoins(world, choice, get_coins());
goto playagain;
break;
case -1:
set_highscore(world, choice, get_score());
set_highcoins(world, choice, get_coins());
break; // do not play again
}
}
}
if (key==KEY_EXIT || key==KEY_MENU)
break;
}
case KEY_EXIT:
// fall through
case KEY_MENU:
return;
}
}
}
void LaunchUI() // Main Menu
void LaunchUI() // Main Menu
{
extern image_t img_mainmenu;
@ -171,10 +183,10 @@ void LaunchUI() // Main Menu
{
mkb_clear();
dimage(0,0,&img_mainmenu);
// Draw world images, but only unlocked ones
//Show unlocked worlds
extern image_t img_w1, img_w2, img_w3, img_w4, img_w5;
switch (get_progress_status())
{
@ -200,26 +212,26 @@ void LaunchUI() // Main Menu
dupdate();
//int key=getkey_opt(GETKEY_REP_ARROWS,0).key;
switch (mkb_getkey())
switch (mkb_getkey())
{
case KEY_UP:
if (choice_y) // >0
choice_y--;
choice_y--;
break;
case KEY_LEFT:
if (choice_x) // >0
choice_x--;
choice_x--;
break;
case (KEY_DOWN):
if (!choice_y) // ==0
choice_y++;
choice_y++;
break;
case (KEY_RIGHT):
if (choice_x!=3) // <3
choice_x++;
choice_x++;
break;
case KEY_EXE:
@ -239,7 +251,7 @@ void LaunchUI() // Main Menu
default:
if (4*choice_y+choice_x<=get_progress_status())
levelchanger(4*choice_y+choice_x);
LevelChanger(4*choice_y+choice_x);
}
break;
@ -276,9 +288,9 @@ int play_level(int w, int l)
while(global_quit==0)
{
wait_next_frame();
frame_id++;
//mario_move();
//mario_move();
world_move();
dclear(C_WHITE);
@ -311,13 +323,13 @@ int play_level(int w, int l)
if (finish_level)
{
quit_refresh();
// TODO ajouter temps au score etc
// TODO ajouter temps au score etc
if (finish_level==1)
sleep_ms(3,3000);
sleep_ms(3,3000);
return finish_level;
}
}
return 0;
}
}

@ -12,7 +12,8 @@ static int lifes=3;
int combo=0;
int combo_id=-10;
int pieces=0;
static int pieces=0;
static unsigned int time_last_piece=0;
int time_id=0;
int time_left=0;
@ -29,6 +30,7 @@ void new_game()
combo=0;
combo_id=-10;
mario_smaller();
mario_immunity=0;
new_level();
time_spent=0;
}
@ -61,6 +63,7 @@ void score_reset()
void score_add_coin()
{
pieces++;
time_last_piece=time_id;
}
void score_add(int i)
@ -85,10 +88,11 @@ 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)
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);
}
@ -96,8 +100,12 @@ void score_display()
{
combo=0;
}
sprintf(str, "c*%d", pieces);
dtext(50,0,str, C_BLACK, C_WHITE);
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)
@ -106,8 +114,10 @@ void score_display()
time_spent++;
}
sprintf(str, "TIME : %d", time_left);
dtext(87-7,0,str, C_BLACK, C_WHITE);
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)
{
@ -132,4 +142,4 @@ int LifesGet() { return lifes; }
void LifesSet(int l) { lifes = l; }
void LifesAdd(int l) { lifes += l; }
void LifesAdd(int l) { lifes += l; }

Loading…
Cancel
Save