Fixed the issue, thanks to Lephénixnoir.

input.states were initialized to 0, which is the value of S_PRESS.
They are now set to S_UP.
This commit is contained in:
KikooDX 2020-09-21 11:21:28 +02:00
parent 7735835ca8
commit 8c1faba253
3 changed files with 17 additions and 5 deletions

View File

@ -29,6 +29,9 @@ typedef struct Input
/* will check for new key inputs and update states[] */
void input_step(Input *input);
/* initialize values */
void input_init(Input *input);
/* display all keys states and information */
void input_draw_debug(Input *input);

View File

@ -26,6 +26,19 @@ void input_step(Input *input)
}
}
void input_init(Input *input)
{
input->keys[K_LEFT] = KEY_LEFT;
input->keys[K_RIGHT] = KEY_RIGHT;
input->keys[K_UP] = KEY_UP;
input->keys[K_DOWN] = KEY_DOWN;
input->keys[K_EXIT] = KEY_EXIT;
for (int i = 0; i < KEYS_COUNT; ++i)
{
input->states[i] = S_UP;
}
}
void input_draw_debug(Input *input)
{
for (int i = 0; i < KEYS_COUNT; ++i)

View File

@ -49,11 +49,7 @@ int play_level(uint level_id)
/* create input manager */
Input input;
input.keys[K_LEFT] = KEY_LEFT;
input.keys[K_RIGHT] = KEY_RIGHT;
input.keys[K_UP] = KEY_UP;
input.keys[K_DOWN] = KEY_DOWN;
input.keys[K_EXIT] = KEY_EXIT;
input_init(&input);
/* UPS control */
volatile int has_ticked = 1;