diff options
| author | Connor Thomson <blumatrikz@gmail.com> | 2026-09-08 18:27:39 -0700 |
|---|---|---|
| committer | Connor Thomson <blumatrikz@gmail.com> | 2026-09-08 18:27:39 -0700 |
| commit | f1ddc12b68b4e4c8087962de25260470e6df2bea (patch) | |
| tree | 7d0440a6402a9b0ef75ded23fa64b68534255bba /src/client/control.c | |
| parent | 6025860a61386bf767b29c3ec5fd0d31285f1056 (diff) | |
Add tuxanci2 files
Diffstat (limited to 'src/client/control.c')
| -rw-r--r-- | src/client/control.c | 84 |
1 files changed, 0 insertions, 84 deletions
diff --git a/src/client/control.c b/src/client/control.c deleted file mode 100644 index bfc2428..0000000 --- a/src/client/control.c +++ /dev/null @@ -1,84 +0,0 @@ -#include <SDL.h> -#include <limits.h> -#include <assert.h> - -#include "main.h" -#include "control.h" - -control_t *control_new(SDLKey arg_up, SDLKey arg_right, SDLKey arg_left, - SDLKey arg_down, SDLKey arg_shot, SDLKey arg_switch) -{ - control_t *tmp; - - tmp = malloc(sizeof(control_t)); - memset(tmp, 0, sizeof(control_t)); - tmp->key[CONTROL_UP] = arg_up; - tmp->key[CONTROL_RIGHT] = arg_right; - tmp->key[CONTROL_LEFT] = arg_left; - tmp->key[CONTROL_DOWN] = arg_down; - tmp->key[CONTROL_SHOT] = arg_shot; - tmp->key[CONTROL_SWITCH] = arg_switch; - - return tmp; -} - -int control_get_key_route(control_t *my_control) -{ - Uint8 *map; - SDLKey ret_key; - int z; - int i; - - assert(my_control != NULL); - - ret_key = CONTROL_NONE; - - map = SDL_GetKeyState(NULL); - - for (i = 0; i < CONTROL_KEY_COUNT_ROUTE; i++) { - if (map[my_control->key[i]] == SDL_PRESSED) { - my_control->count[i]++; - } else { - my_control->count[i] = 0; - } - } - - z = INT_MAX; - - for (i = 0; i < CONTROL_KEY_COUNT_ROUTE; i++) { - if (my_control->count[i] > 0 && - my_control->count[i] < z && - map[my_control->key[i]] == SDL_PRESSED) { - z = my_control->count[i]; - ret_key = i; - } - } - - return ret_key; -} - -int control_get_key_action(control_t *my_control) -{ - Uint8 *map; - - assert(my_control != NULL); - - map = SDL_GetKeyState(NULL); - - if (map[my_control->key[CONTROL_SHOT]] == SDL_PRESSED) { - return CONTROL_SHOT; - } - - if (map[my_control->key[CONTROL_SWITCH]] == SDL_PRESSED) { - return CONTROL_SWITCH; - } - - return CONTROL_NONE; -} - -void control_destroy(control_t *my_control) -{ - assert(my_control != NULL); - - free(my_control); -} |