diff --git a/src/gameloop.c b/src/gameloop.c index c7b3f44..226907a 100644 --- a/src/gameloop.c +++ b/src/gameloop.c @@ -427,6 +427,12 @@ int gameLoop ( &player.inventory.offhand ); } + + if (!gamePopup && inputs->numPressed != 0 && inputs->numPressed != 10) { + player.inventory.hotbarSelect = inputs->numPressed - 1; + + inputs->numPressed = 0; + } } #ifndef small diff --git a/src/main.c b/src/main.c index 46dbbb5..9a68bd4 100644 --- a/src/main.c +++ b/src/main.c @@ -137,6 +137,10 @@ int handleEvent (Inputs *inputs, const u_int8_t *keyboard, SDL_Event event) { inputs->keyboard_F = keyboard[SDL_SCANCODE_F]; inputs->keySym = event.key.keysym.sym; + + if (event.key.keysym.scancode >= SDL_SCANCODE_1 && event.key.keysym.scancode <= SDL_SCANCODE_0) { + inputs->numPressed = event.key.keysym.scancode - SDL_SCANCODE_1 + 1; + } } break; diff --git a/src/main.h b/src/main.h index eabd1ac..380a109 100644 --- a/src/main.h +++ b/src/main.h @@ -31,6 +31,8 @@ typedef struct { int keyTyped; int keySym; + + int numPressed; } Inputs; int controlLoop(Inputs *inputs, const u_int8_t *keyboard);