diff options
author | Johnny Richard <johnny@johnnyrichard.com> | 2021-11-14 01:27:15 +0100 |
---|---|---|
committer | Johnny Richard <johnny@johnnyrichard.com> | 2021-11-14 01:27:15 +0100 |
commit | e415b62a2e85f44e6ff285e08b16525605d2fc0f (patch) | |
tree | f31f2ad1c8309b4fc5c5bfde2172efdb10076db3 /src/main.c | |
parent | f584871064596b52efe12c2f8258f0839f6eb0fa (diff) |
controller_t: Reduce memory usage using bitwise
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -74,7 +74,7 @@ main (int argc, SDL_Rect rect = { .x = 0, .y = 0, .w = 20, .h = 20 }; bool quit = false; - controller_t controller = {0}; + controller_t ctrl = {0}; while (!quit) { screenSurface = SDL_GetWindowSurface(window); @@ -89,13 +89,13 @@ main (int argc, if (event.type == SDL_QUIT) { quit = true; } - controller_update(&controller, &event); + controller_update(&ctrl, &event); } - if (controller.up) rect.y -= 1; - if (controller.down) rect.y += 1; - if (controller.left) rect.x -= 1; - if (controller.right) rect.x += 1; + if (controller_is_up_pressed(&ctrl)) rect.y -= 1; + if (controller_is_down_pressed(&ctrl)) rect.y += 1; + if (controller_is_left_pressed(&ctrl)) rect.x -= 1; + if (controller_is_right_pressed(&ctrl)) rect.x += 1; SDL_FillRect( screenSurface, |