#include #include #include #include #include #include #include #include #include #include #include extern image_t img_mainmenu; 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_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_EXE || key==KEY_SHIFT) { // Determine mode if (choice_x==3 && choice_y==1) break; if (choice_x==2 && choice_y==1) break; } if (key==KEY_EXIT || key==KEY_MENU) break; } } extern image_t img_error; GNORETURN void system_error(uint32_t code) { timer_stop(0); dimage(0,0,&img_error); dupdate(); while(1) getkey(); } int frame_id; int callback(volatile void *arg) { volatile int *has_ticked = arg; *has_ticked = 1; return 0; } 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) { if (has_ticked) { has_ticked=0; frame_id++; //mario_move(); world_move(); dclear(C_WHITE); world_draw(mario.p.x,mario.p.y); score_display(); dupdate(); if (mario_dead || finish_level) { return 0; } } else sleep_ms(3,1); } }