- Afegit soport per a ratolí
This commit is contained in:
@@ -46,4 +46,22 @@ namespace input
|
|||||||
keypressed = key;
|
keypressed = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int mouseX()
|
||||||
|
{
|
||||||
|
int x;
|
||||||
|
SDL_GetMouseState(&x, NULL);
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
int mouseY()
|
||||||
|
{
|
||||||
|
int y;
|
||||||
|
SDL_GetMouseState(NULL, &y);
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool mouseBtn(int btn)
|
||||||
|
{
|
||||||
|
return (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(btn));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,4 +27,9 @@ namespace input
|
|||||||
|
|
||||||
void updateKey(uint8_t key);
|
void updateKey(uint8_t key);
|
||||||
void updateKeypressed(uint8_t key);
|
void updateKeypressed(uint8_t key);
|
||||||
|
|
||||||
|
int mouseX();
|
||||||
|
int mouseY();
|
||||||
|
bool mouseBtn(int btn);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -46,6 +46,24 @@ void game::init()
|
|||||||
|
|
||||||
int sx=1, sy=0;
|
int sx=1, sy=0;
|
||||||
|
|
||||||
|
void print(int x, int y, int num)
|
||||||
|
{
|
||||||
|
int digits=0;
|
||||||
|
bool sign = num < 0;
|
||||||
|
num = SDL_abs(num);
|
||||||
|
int n = num;
|
||||||
|
while (n>0) {n=n/10;digits++;}
|
||||||
|
if (sign) digits++;
|
||||||
|
x=x+digits*4;
|
||||||
|
if (num==0) draw::draw(x+4,y,5,7,0,120);
|
||||||
|
while (num>0)
|
||||||
|
{
|
||||||
|
draw::draw(x,y,5,7,(num%10)*5,120);
|
||||||
|
num=num/10;
|
||||||
|
x=x-4;
|
||||||
|
}
|
||||||
|
if (sign) draw::draw(x,y,5,7,50,120);
|
||||||
|
}
|
||||||
|
|
||||||
bool game::loop()
|
bool game::loop()
|
||||||
{
|
{
|
||||||
@@ -54,6 +72,7 @@ bool game::loop()
|
|||||||
ii++;if(ii>3)ii=0;
|
ii++;if(ii>3)ii=0;
|
||||||
restart();
|
restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
actor::update(actor::getFirst());
|
actor::update(actor::getFirst());
|
||||||
actor::reorder();
|
actor::reorder();
|
||||||
|
|
||||||
@@ -62,6 +81,12 @@ bool game::loop()
|
|||||||
actor::draw(actor::getFirst());
|
actor::draw(actor::getFirst());
|
||||||
room::draw2();
|
room::draw2();
|
||||||
//draw::draw(148+sx*2-sy*2, 67+sx+sy,24,24,24,0);
|
//draw::draw(148+sx*2-sy*2, 67+sx+sy,24,24,24,0);
|
||||||
|
|
||||||
|
print(0,0,input::mouseX()/3);
|
||||||
|
print(0,20,input::mouseY()/3);
|
||||||
|
print(0,30,input::mouseBtn(1)?1:0);
|
||||||
|
print(0,40,input::mouseBtn(2)?1:0);
|
||||||
|
print(0,50,input::mouseBtn(3)?1:0);
|
||||||
draw::render();
|
draw::render();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user