sort functions better based on when they're called

This commit is contained in:
Quinn
2024-08-16 00:04:13 +02:00
parent 5d53df673d
commit 7026f826c5

View File

@@ -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;