#include "keyboard.h" #include "mario.h" #include "score.h" #include #include #include #include mkey_t keys[6]={0}; extern image_t img_menu_pause; extern image_t img_select_arrow; static int konami[]={KEY_UP,KEY_UP,KEY_DOWN,KEY_DOWN,KEY_LEFT,KEY_RIGHT,KEY_LEFT,KEY_RIGHT,KEY_SHIFT,KEY_ALPHA}; int menu_pause() // 1 exit, 0 continue { key_event_t e; e=pollevent(); while(e.type!=KEYEV_NONE) e=pollevent(); int key; int choice=0; int x=64-img_menu_pause.width/2; int y=32-img_menu_pause.height/2; for (int i=0; i<6; i++) keys[i]=0; while (1) { e=pollevent(); while(e.type!=KEYEV_NONE) { if (keydown(KEY_EXE)) return choice; if (keydown(KEY_UP)) choice=0; if (keydown(KEY_DOWN)) choice=1; if (keydown(KEY_EXIT)) return 0; if (keydown(KEY_MENU)) return 1; if (keydown(KEY_F1)) { e=pollevent(); int a=0; while (a<10) { if (e.type==KEYEV_DOWN) { if (e.key==konami[a]) a++; else break; } if (keydown(KEY_EXIT)) break; if (a==10) { mario_bigger(); mario_has_bullets=1; lifes=50; extern image_t img_dev; dimage(0,0,&img_dev); dupdate(); sleep_ms(3,1000); return 0; } else e=pollevent(); } } e=pollevent(); } dimage(x,y,&img_menu_pause); dimage(x+2, y+2+7*choice, &img_select_arrow); dupdate(); sleep_ms(3,1); } } void update_keyboard() { key_event_t e; e=pollevent(); int menu=0; for (int i=0; i<6; i++) if (keys[i]==2) keys[i]=1; while(e.type!=KEYEV_NONE) { mkey_t k = MK_NONE; if(e.key==KEY_LEFT) k=MK_LEFT; if(e.key==KEY_RIGHT) k=MK_RIGHT; if(e.key==KEY_SHIFT) k=MK_JUMP1; if(e.key==KEY_UP) k=MK_JUMP2; if(e.key==KEY_DOWN) k=MK_LITTLE; if(e.key==KEY_ALPHA) k=MK_RUN; if(keydown(KEY_EXIT)) menu=1; if (k!=MK_NONE) { if (e.type==KEYEV_DOWN) { keys[k]=2; } if (e.type==KEYEV_UP) { keys[k]=0; } } e=pollevent(); } if (menu) global_quit=menu_pause(); }