From 7026f826c502262a4b221a961b5e2e3bfadd04e9 Mon Sep 17 00:00:00 2001 From: Quinn <99677023+thepigeongenerator@users.noreply.github.com> Date: Fri, 16 Aug 2024 00:04:13 +0200 Subject: [PATCH] sort functions better based on when they're called --- src/level.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/level.c b/src/level.c index c7b055f..884f442 100644 --- a/src/level.c +++ b/src/level.c @@ -47,6 +47,27 @@ void level_init(Level* level) { } } +// updates the player's "bouncer" +static void update_player(Bouncer* bouncer, Ball* ball, const Uint8* keys) { + // if move bouncer LEFT + if (keys[SDL_SCANCODE_A] || keys[SDL_SCANCODE_LEFT]) { + ball->moving = true; + + if (bouncer->pos.x < 0 == false) { + bouncer->pos.x -= BOUNCER_SPEED; + } + } + + // if move bouncer RIGHT + if (keys[SDL_SCANCODE_D] || keys[SDL_SCANCODE_RIGHT]) { + ball->moving = true; + + if ((bouncer->pos.x + bouncer->width) > SCREEN_WIDTH == false) { + bouncer->pos.x += BOUNCER_SPEED; // increase the bouncer pos + } + } +} + // updates the player's ball static void update_ball(Level* level, Ball* ball, Bouncer* bouncer) { // update ball position @@ -115,27 +136,6 @@ static void update_ball(Level* level, Ball* ball, Bouncer* bouncer) { } } -// updates the player's "bouncer" -static void update_player(Bouncer* bouncer, Ball* ball, const Uint8* keys) { - // if move bouncer LEFT - if (keys[SDL_SCANCODE_A] || keys[SDL_SCANCODE_LEFT]) { - ball->moving = true; - - if (bouncer->pos.x < 0 == false) { - bouncer->pos.x -= BOUNCER_SPEED; - } - } - - // if move bouncer RIGHT - if (keys[SDL_SCANCODE_D] || keys[SDL_SCANCODE_RIGHT]) { - ball->moving = true; - - if ((bouncer->pos.x + bouncer->width) > SCREEN_WIDTH == false) { - bouncer->pos.x += BOUNCER_SPEED; // increase the bouncer pos - } - } -} - //updates the level void level_update(Level* level, const Uint8* keys) { Bouncer* bouncer = &level->bouncer;