diff options
author | Charadon <dev@iotib.net> | 2022-06-23 19:08:04 -0400 |
---|---|---|
committer | Charadon <dev@iotib.net> | 2022-06-23 19:08:04 -0400 |
commit | c020a309846d9d20be1badd28e592da161d1761f (patch) | |
tree | 3261c4d210c8bdda45db82186d7153a3dbe575b3 /src/enemy.c | |
parent | 3d0915d1265280ecb070da15cd7a31e9a0b16e7c (diff) | |
download | Pong-C-c020a309846d9d20be1badd28e592da161d1761f.tar.gz |
Migrated code to ANSI C
Diffstat (limited to 'src/enemy.c')
-rw-r--r-- | src/enemy.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/enemy.c b/src/enemy.c index 56c7d87..b46ce15 100644 --- a/src/enemy.c +++ b/src/enemy.c @@ -8,8 +8,9 @@ void enemy(struct Players *Enemy, struct Balls ball) { if(CurrentTick > Enemy->NextTick) { RunThisManyTimes = (CurrentTick - Enemy->NextTick); } - for (int i = 0; i <= RunThisManyTimes; i++) { - // Changes direction + int i = 0; + for (i = 0; i <= RunThisManyTimes; i++) { + /* Changes direction */ if (!CheckCollisionRecs(ball.HitBox, Enemy->BallDetector)) { if (Enemy->Y+120 > ball.Y) { Enemy->Direction = 0; @@ -20,7 +21,7 @@ void enemy(struct Players *Enemy, struct Balls ball) { Enemy->Direction = 3; } - // Moves + /* Moves */ switch(Enemy->Direction) { case 0: Enemy->Y -= 15; @@ -32,14 +33,14 @@ void enemy(struct Players *Enemy, struct Balls ball) { break; } - // Prevents from going off screen. + /* Prevents from going off screen. */ if ( Enemy->Y > 480 ) { Enemy->Y = 480; } else if (Enemy->Y < 0) { Enemy->Y = 0; } - // Updates hitbox and detector + /* Updates hitbox and detector */ Enemy->HitBox.y = Enemy->Y; Enemy->BallDetector.y = Enemy->Y+80; } |