added level choosing interface

This commit is contained in:
Milang 2020-01-13 20:26:04 +01:00
parent fadf1b6888
commit 8210034071
1 changed files with 66 additions and 5 deletions

View File

@ -13,12 +13,64 @@
#include <save.h>
#include <config.h>
extern image_t img_mainmenu;
static void levelchanger(int w)
{
int play_level(int l);
extern image_t img_levelchanger;
int choice=0;
// x y, first button coordinates and size
const int xt = 19, yt = 7, wt = 6, ht = 6;
while (1)
{
keyboard_clear();
dimage(0,0,&img_levelchanger);
drect(xt+(2+wt)*choice, yt, xt+(wt+2)*choice+wt,yt+ht, C_INVERT);
dupdate();
//int key=getkey_opt(GETKEY_REP_ARROWS,0).key;
int key=getkey_custom();
if (key==KEY_LEFT && choice>0)
choice--;
if (key==KEY_RIGHT && choice<8)
choice++;
if (key==KEY_EXE || key==KEY_SHIFT)
{
if (choice==8)
{
play_level(0); // Todo : add score lifes etc...
}
else
{
mario_smaller();
mario_immunity=0;
play_level(choice);
}
}
if (key==KEY_EXIT || key==KEY_MENU)
break;
}
}
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)
@ -78,17 +130,19 @@ void launch_ui()
else
world_chosen=choice_x;
if (world_chosen<=get_progress_status())
play_level(world_chosen);
levelchanger(world_chosen);
}
}
if (key==KEY_EXIT || key==KEY_MENU)
break;
}
}
int frame_id;
int callback(volatile void *arg)
{
@ -109,6 +163,8 @@ int play_level(int l)
//int finish_status=0; // FAil
finish_level=0; mario_dead=0;
set_level(l);
if (w_current==0)
return 0;
reset_camera();
while(global_quit==0)
{
@ -124,11 +180,16 @@ int play_level(int l)
score_display();
dupdate();
if (mario_dead || finish_level)
if (mario_dead)
{
timer_stop(0);
return 0;
}
if (finish_level)
{
timer_stop(0);
return 1;
}
}
else