about summary refs log tree commit diff stats
path: root/src/ball.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ball.c')
-rw-r--r--src/ball.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/ball.c b/src/ball.c
index 0e6b62f..f6f5362 100644
--- a/src/ball.c
+++ b/src/ball.c
@@ -1,7 +1,6 @@
 #include "pong.h"
 
 void ball(Rectangle *Player, Rectangle *Enemy, struct Balls *Ball, int *PlayerScore, int *EnemyScore) {
-	
 	bool NoEnemy = false;
 	if (Enemy == NULL) {
 		NoEnemy = true;
@@ -9,7 +8,7 @@ void ball(Rectangle *Player, Rectangle *Enemy, struct Balls *Ball, int *PlayerSc
 
 	/* Moves */
 	int CurrentTick = SDL_AtomicGet(&Ticks);
-	if(Ball->NextTick <= CurrentTick){
+	if (Ball->NextTick <= CurrentTick) {
 		int RunThisManyTimes = 0;
 		if (CurrentTick > Ball->NextTick) {
 			RunThisManyTimes = (CurrentTick - Ball->NextTick);
@@ -57,12 +56,12 @@ void ball(Rectangle *Player, Rectangle *Enemy, struct Balls *Ball, int *PlayerSc
 				}
 			}
 			/* Bounce ball if touches top or bottom of screen. */
-			if ( (Ball->Y+32 >= 720 && Ball->Angle >=1) || (Ball->Y <= 0 && Ball->Angle <= -1) ) {
+			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;
+		Ball->NextTick = SDL_AtomicGet(&Ticks) + 1;
 	}
 
 	/* Calculates score and resets ball. */
@@ -70,18 +69,18 @@ void ball(Rectangle *Player, Rectangle *Enemy, struct Balls *Ball, int *PlayerSc
 	if (Ball->X < 0 && NoEnemy == false) {
 		*EnemyScore += 1;
 		Scored = true;
-	} else if (Ball ->X > 1280 && NoEnemy == false) {
+	} else if (Ball->X > 1280 && NoEnemy == false) {
 		*PlayerScore += 1;
 		Scored = true;
-	} else if (Ball->X > (1280-32) && NoEnemy == true) {
+	} else if (Ball->X > (1280 - 32) && NoEnemy == true) {
 		*PlayerScore += 1;
 		Scored = false;
 		Ball->Direction = LEFT;
 		play_audio(SOUND_PLAYER_SCORE);
-	} 
+	}
 	if (Scored == true) {
-		Ball->X = 1280/2.0f;
-		Ball->Y = 720/2.0f;
+		Ball->X = 1280 / 2.0f;
+		Ball->Y = 720 / 2.0f;
 		Ball->Speed = 3.0f;
 		Ball->Angle = 0;
 	}