2019-11-21 19:30:54 +01:00
|
|
|
#include "keyboard.h"
|
|
|
|
#include "mario.h"
|
|
|
|
#include <gint/keyboard.h>
|
2019-11-24 14:28:04 +01:00
|
|
|
#include <gint/display.h>
|
|
|
|
#include <gint/timer.h>
|
2019-11-30 13:57:18 +01:00
|
|
|
#include <gint/clock.h>
|
2019-11-21 19:30:54 +01:00
|
|
|
|
|
|
|
mkey_t keys[6]={0};
|
|
|
|
|
2019-11-24 14:28:04 +01:00
|
|
|
extern image_t img_menu_pause;
|
|
|
|
extern image_t img_select_arrow;
|
|
|
|
|
|
|
|
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;
|
|
|
|
e=pollevent();
|
|
|
|
}
|
|
|
|
|
|
|
|
dimage(x,y,&img_menu_pause);
|
|
|
|
dimage(x+2, y+2+7*choice, &img_select_arrow);
|
|
|
|
dupdate();
|
2019-11-30 13:57:18 +01:00
|
|
|
sleep_ms(3,1);
|
2019-11-24 14:28:04 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-21 19:30:54 +01:00
|
|
|
void update_keyboard()
|
|
|
|
{
|
|
|
|
key_event_t e;
|
|
|
|
e=pollevent();
|
2019-11-24 14:28:04 +01:00
|
|
|
int menu=0;
|
2019-11-30 13:57:18 +01:00
|
|
|
for (int i=0; i<6; i++)
|
|
|
|
if (keys[i]==2) keys[i]=1;
|
2019-11-21 19:30:54 +01:00
|
|
|
while(e.type!=KEYEV_NONE)
|
2019-11-24 14:28:04 +01:00
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
2019-11-30 13:57:18 +01:00
|
|
|
keys[k]=2;
|
2019-11-24 14:28:04 +01:00
|
|
|
}
|
|
|
|
if (e.type==KEYEV_UP)
|
|
|
|
{
|
|
|
|
keys[k]=0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
e=pollevent();
|
|
|
|
}
|
|
|
|
if (menu)
|
|
|
|
global_quit=menu_pause();
|
2019-11-21 19:30:54 +01:00
|
|
|
}
|