- Treballant en algo de UI
This commit is contained in:
@@ -1,15 +1,19 @@
|
||||
#include "jinput.h"
|
||||
#include <SDL2/SDL.h>
|
||||
#include "jdraw.h"
|
||||
|
||||
namespace input
|
||||
{
|
||||
static const uint8_t *keys = nullptr;
|
||||
static uint8_t keypressed = 0;
|
||||
static uint8_t keydown = 0;
|
||||
static uint8_t btnClicked = 0;
|
||||
static int screen_zoom = 1;
|
||||
|
||||
void init()
|
||||
void init(const int zoom)
|
||||
{
|
||||
keys = SDL_GetKeyboardState(NULL);
|
||||
screen_zoom = zoom;
|
||||
}
|
||||
|
||||
// Determina si la tecla especificada està sent polsada ara mateix
|
||||
@@ -46,22 +50,33 @@ namespace input
|
||||
keypressed = key;
|
||||
}
|
||||
|
||||
void updateClk(uint8_t btn)
|
||||
{
|
||||
btnClicked = btn;
|
||||
}
|
||||
|
||||
int mouseX()
|
||||
{
|
||||
int x;
|
||||
SDL_GetMouseState(&x, NULL);
|
||||
return x;
|
||||
return x/screen_zoom;
|
||||
}
|
||||
|
||||
int mouseY()
|
||||
{
|
||||
int y;
|
||||
SDL_GetMouseState(NULL, &y);
|
||||
return y;
|
||||
return y/screen_zoom;
|
||||
}
|
||||
|
||||
bool mouseBtn(int btn)
|
||||
{
|
||||
return (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(btn));
|
||||
}
|
||||
|
||||
bool mouseClk(int btn)
|
||||
{
|
||||
return btnClicked == btn;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user