diff options
Diffstat (limited to 'src/ball.c')
-rw-r--r-- | src/ball.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/ball.c b/src/ball.c index af210bb..0e6b62f 100644 --- a/src/ball.c +++ b/src/ball.c @@ -7,14 +7,15 @@ void ball(Rectangle *Player, Rectangle *Enemy, struct Balls *Ball, int *PlayerSc NoEnemy = true; } - // Moves + /* Moves */ int CurrentTick = SDL_AtomicGet(&Ticks); if(Ball->NextTick <= CurrentTick){ int RunThisManyTimes = 0; if (CurrentTick > Ball->NextTick) { RunThisManyTimes = (CurrentTick - Ball->NextTick); } - for (int i = 0; i <= RunThisManyTimes; i++) { + int i = 0; + for (i = 0; i <= RunThisManyTimes; i++) { Ball->Y += Ball->Angle; if (Ball->Direction == LEFT) { Ball->X -= Ball->Speed; @@ -22,11 +23,11 @@ void ball(Rectangle *Player, Rectangle *Enemy, struct Balls *Ball, int *PlayerSc Ball->X += Ball->Speed; } - // Moves hitbox with ball. + /* Moves hitbox with ball. */ Ball->HitBox.x = Ball->X; Ball->HitBox.y = Ball->Y; - // Check collisions against players. + /* Check collisions against players. */ if (CheckCollisionRecs(*Player, Ball->HitBox) && Ball->Direction == LEFT) { Ball->Direction = RIGHT; Ball->Speed *= 1.5f; @@ -55,18 +56,16 @@ void ball(Rectangle *Player, Rectangle *Enemy, struct Balls *Ball, int *PlayerSc play_audio(SOUND_BOUNCE); } } - // Bounce ball if touches top or bottom of screen. + /* Bounce ball if touches top or bottom of screen. */ if ( (Ball->Y+32 >= 720 && Ball->Angle >=1) || (Ball->Y <= 0 && Ball->Angle <= -1) ) { Ball->Angle *= -1; play_audio(SOUND_BOUNCE); } } Ball->NextTick = SDL_AtomicGet(&Ticks)+1; -// printf("%d,%d\n", SDL_AtomicGet(&Ticks), Ball->NextTick); } -// printf("%d,%d\n", SDL_AtomicGet(&Ticks), Ball->NextTick); - // Calculates score and resets ball. + /* Calculates score and resets ball. */ bool Scored = false; if (Ball->X < 0 && NoEnemy == false) { *EnemyScore += 1; |