add menu with world selection
BIN
SuperCbr.g1a
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 9.8 KiB |
After Width: | Height: | Size: 705 B |
After Width: | Height: | Size: 703 B |
After Width: | Height: | Size: 708 B |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 673 B |
1142
build-fx/map
|
@ -1,5 +1,6 @@
|
|||
build-fx/src/levelchanger.c.o: src/levelchanger.c include/levelchanger.h \
|
||||
include/keyboard.h include/mario.h include/box.h include/world.h
|
||||
include/keyboard.h include/mario.h include/box.h include/world.h \
|
||||
include/score.h include/level.h include/save.h
|
||||
|
||||
include/levelchanger.h:
|
||||
|
||||
|
@ -10,3 +11,9 @@ include/mario.h:
|
|||
include/box.h:
|
||||
|
||||
include/world.h:
|
||||
|
||||
include/score.h:
|
||||
|
||||
include/level.h:
|
||||
|
||||
include/save.h:
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
build-fx/src/main.c.o: src/main.c include/world.h include/mario.h \
|
||||
include/box.h include/level.h include/score.h include/ennemi.h
|
||||
build-fx/src/main.c.o: src/main.c include/levelchanger.h include/world.h \
|
||||
include/mario.h include/box.h include/level.h include/score.h \
|
||||
include/ennemi.h
|
||||
|
||||
include/levelchanger.h:
|
||||
|
||||
include/world.h:
|
||||
|
||||
|
|
|
@ -13,4 +13,6 @@ void set_highscore(int world, int level, int score);
|
|||
int get_best_time(int world, int level);
|
||||
void set_best_time(int world, int level, int score);
|
||||
|
||||
int get_progress_status();
|
||||
|
||||
#endif
|
|
@ -3,10 +3,14 @@
|
|||
#include <gint/display.h>
|
||||
#include <gint/keyboard.h>
|
||||
#include <gint/timer.h>
|
||||
#include <gint/clock.h>
|
||||
|
||||
#include <keyboard.h>
|
||||
#include <mario.h>
|
||||
#include <world.h>
|
||||
#include <score.h>
|
||||
#include <level.h>
|
||||
#include <save.h>
|
||||
|
||||
extern image_t img_mainmenu;
|
||||
|
||||
|
@ -14,13 +18,48 @@ void launch_ui()
|
|||
{
|
||||
keyboard_clear();
|
||||
extern image_t img_mainmenu;
|
||||
const int xt=17,yt=9;
|
||||
int choice_x=0, choice_y=0;
|
||||
while (1)
|
||||
{
|
||||
keyboard_clear();
|
||||
dimage(0,0,&img_mainmenu);
|
||||
|
||||
//Show unlocked worlds
|
||||
|
||||
extern image_t img_w1, img_w2, img_w3, img_w4, img_w5;
|
||||
switch (get_progress_status())
|
||||
{
|
||||
case 4:
|
||||
dimage(xt, yt+24, &img_w5);
|
||||
|
||||
case 3:
|
||||
dimage(xt+72, yt, &img_w4);
|
||||
|
||||
case 2:
|
||||
dimage(xt+48, yt, &img_w3);
|
||||
|
||||
case 1:
|
||||
dimage(xt+24, yt, &img_w2);
|
||||
|
||||
case 0:
|
||||
dimage(xt, yt, &img_w1);
|
||||
}
|
||||
|
||||
drect(xt+24*choice_x,yt+24*choice_y, xt+24*choice_x+20,yt+24*choice_y+20, C_INVERT);
|
||||
|
||||
dupdate();
|
||||
int key=getkey().key;
|
||||
if (key==KEY_EXIT)
|
||||
if (key==KEY_UP && choice_y>0)
|
||||
choice_y--;
|
||||
if (key==KEY_LEFT && choice_x>0)
|
||||
choice_x--;
|
||||
if (key==KEY_DOWN && choice_y<1)
|
||||
choice_y++;
|
||||
if (key==KEY_RIGHT && choice_x<3)
|
||||
choice_x++;
|
||||
|
||||
if (key==KEY_EXIT || key==KEY_MENU)
|
||||
break;
|
||||
|
||||
}
|
||||
|
@ -49,9 +88,18 @@ int callback(volatile void *arg)
|
|||
|
||||
|
||||
|
||||
void play_level(int l)
|
||||
int play_level(int l)
|
||||
{
|
||||
set_level(l);
|
||||
|
||||
|
||||
|
||||
volatile int has_ticked = 1;
|
||||
timer_setup(0, timer_delay(0, 50000), timer_Po_4, callback, &has_ticked);
|
||||
timer_start(0);
|
||||
|
||||
//int finish_status=0; // FAil
|
||||
finish_level=0;
|
||||
set_level(l);
|
||||
while(global_quit==0)
|
||||
{
|
||||
|
@ -67,35 +115,11 @@ void play_level(int l)
|
|||
score_display();
|
||||
|
||||
dupdate();
|
||||
if (mario_dead==1)
|
||||
if (mario_dead || finish_level)
|
||||
{
|
||||
mario_dead=0;
|
||||
finish_level=0;
|
||||
|
||||
}
|
||||
if (finish_level==0)
|
||||
{
|
||||
lifes--;
|
||||
mario_smaller();
|
||||
set_level(current_level);
|
||||
extern image_t img_new_level;
|
||||
dimage(0,0,&img_new_level);
|
||||
char lvl[4];
|
||||
get_lvl_id(current_level, lvl);
|
||||
dtext(57,28, lvl, C_WHITE, C_BLACK);
|
||||
sprintf(lvl, "%d", lifes);
|
||||
dtext(65,54, lvl, C_WHITE, C_BLACK);
|
||||
dupdate();
|
||||
sleep_ms(3,1000);
|
||||
sleep_ms(3,1000);
|
||||
sleep_ms(3,1000);
|
||||
dclear(C_BLACK);
|
||||
}
|
||||
if (finish_level>=1)
|
||||
{
|
||||
current_level+=finish_level;
|
||||
set_level(current_level);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
sleep_ms(3,1);
|
||||
|
|
|
@ -25,9 +25,6 @@ int main(void)
|
|||
ll_set_panic();
|
||||
|
||||
|
||||
timer_setup(0, timer_delay(0, 50000), timer_Po_4, callback, &has_ticked);
|
||||
timer_start(0);
|
||||
set_level(0);
|
||||
int current_level=0;
|
||||
launch_ui();
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ uint32_t level_highscores [NB_MONDES] [WORLD_RUN_ENTRY]={0};
|
|||
|
||||
uint32_t level_best_times [NB_MONDES] [WORLD_RUN_ENTRY];
|
||||
|
||||
uint32_t progress_status=1; // world 1 only
|
||||
uint32_t progress_status=0; // world 1 only
|
||||
|
||||
static uint32_t checksum1;
|
||||
|
||||
|
@ -35,4 +35,7 @@ int get_best_time(int world, int level)
|
|||
void set_best_time(int world, int level, int score)
|
||||
{
|
||||
level_best_times[world%NB_MONDES][level%WORLD_RUN_ENTRY]=score;
|
||||
}
|
||||
}
|
||||
|
||||
int get_progress_status()
|
||||
{ return progress_status; }
|