From e415b62a2e85f44e6ff285e08b16525605d2fc0f Mon Sep 17 00:00:00 2001 From: Johnny Richard Date: Sun, 14 Nov 2021 01:27:15 +0100 Subject: controller_t: Reduce memory usage using bitwise --- src/main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 2c71864..b8e723b 100644 --- a/src/main.c +++ b/src/main.c @@ -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, -- cgit v1.2.3