diff options
author | Charadon <dev@iotib.net> | 2022-10-12 19:33:13 -0400 |
---|---|---|
committer | Charadon <dev@iotib.net> | 2022-10-12 19:33:13 -0400 |
commit | 1e5c179edbae849d185ab9f2be95233ee60cacbf (patch) | |
tree | bc044d8469428e6ac90e9c2aae6c348f6734f3f8 /src/enemy.c | |
parent | 67ac76476ccd5c7cfe9e41f023bee96345710a55 (diff) | |
download | Pong-C-1e5c179edbae849d185ab9f2be95233ee60cacbf.tar.gz |
Fixed formatting FINALLY
Diffstat (limited to 'src/enemy.c')
-rw-r--r-- | src/enemy.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/enemy.c b/src/enemy.c index b46ce15..80ef7f5 100644 --- a/src/enemy.c +++ b/src/enemy.c @@ -1,18 +1,19 @@ -#include "pong.h" #include <SDL2/SDL_atomic.h> +#include "pong.h" + void enemy(struct Players *Enemy, struct Balls ball) { int CurrentTick = SDL_AtomicGet(&Ticks); int RunThisManyTimes = 0; if (Enemy->NextTick <= CurrentTick) { - if(CurrentTick > Enemy->NextTick) { + if (CurrentTick > Enemy->NextTick) { RunThisManyTimes = (CurrentTick - Enemy->NextTick); } int i = 0; for (i = 0; i <= RunThisManyTimes; i++) { /* Changes direction */ if (!CheckCollisionRecs(ball.HitBox, Enemy->BallDetector)) { - if (Enemy->Y+120 > ball.Y) { + if (Enemy->Y + 120 > ball.Y) { Enemy->Direction = 0; } else if (Enemy->Y < ball.Y) { Enemy->Direction = 1; @@ -22,7 +23,7 @@ void enemy(struct Players *Enemy, struct Balls ball) { } /* Moves */ - switch(Enemy->Direction) { + switch (Enemy->Direction) { case 0: Enemy->Y -= 15; break; @@ -34,17 +35,17 @@ void enemy(struct Players *Enemy, struct Balls ball) { } /* Prevents from going off screen. */ - if ( Enemy->Y > 480 ) { + if (Enemy->Y > 480) { Enemy->Y = 480; } else if (Enemy->Y < 0) { Enemy->Y = 0; } - + /* Updates hitbox and detector */ Enemy->HitBox.y = Enemy->Y; - Enemy->BallDetector.y = Enemy->Y+80; + Enemy->BallDetector.y = Enemy->Y + 80; } - Enemy->NextTick = SDL_AtomicGet(&Ticks)+1; + Enemy->NextTick = SDL_AtomicGet(&Ticks) + 1; } return; } |