about summary refs log tree commit diff stats
path: root/src/marathon.c
diff options
context:
space:
mode:
authorCharadon <dev@iotib.net>2022-06-23 19:08:04 -0400
committerCharadon <dev@iotib.net>2022-06-23 19:08:04 -0400
commitc020a309846d9d20be1badd28e592da161d1761f (patch)
tree3261c4d210c8bdda45db82186d7153a3dbe575b3 /src/marathon.c
parent3d0915d1265280ecb070da15cd7a31e9a0b16e7c (diff)
downloadPong-C-c020a309846d9d20be1badd28e592da161d1761f.tar.gz
Migrated code to ANSI C
Diffstat (limited to 'src/marathon.c')
-rw-r--r--src/marathon.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/src/marathon.c b/src/marathon.c
index 07a9fe3..2140b08 100644
--- a/src/marathon.c
+++ b/src/marathon.c
@@ -3,7 +3,7 @@
 void leaderboard_record(int Score) {
     bool LeaderBoardGoing = true;
     
-    // Create Leaderboard struct
+    /* Create Leaderboard struct */
     #define MAX_CHARACTERS 16
     struct {
         char Name[MAX_CHARACTERS];
@@ -11,16 +11,17 @@ void leaderboard_record(int Score) {
     } LeaderboardEntry;
     LeaderboardEntry.Score = Score;
 
-    // Init strings
+    /* Init strings */
     int16_t CharacterNumber = 0;
     int Key = 0;
-    for(int i = 0; i < sizeof(LeaderboardEntry.Name); i++) {
+	int i = 0;
+    for(i = 0; i < sizeof(LeaderboardEntry.Name); i++) {
         LeaderboardEntry.Name[i] = '\0';
     }
     char Scored[8192];
     snprintf(Scored, sizeof(Scored), "You Scored: %d", LeaderboardEntry.Score);
 
-    // Init Camera
+    /* Init Camera */
     Camera2D MainCamera;
         MainCamera.target = (Vector2){0, 0};
         MainCamera.offset = (Vector2){0, 0};
@@ -61,7 +62,7 @@ void leaderboard_record(int Score) {
 	char LeaderboardFilePath[8192];
 	snprintf(LeaderboardFilePath, sizeof(LeaderboardFilePath), "%s/leaderboard.txt", LeaderboardDirectory);
 	FILE *LeaderboardFile;
-    // Put save to file here.
+    /* Put save to file here. */
     if ((LeaderboardFile = fopen(LeaderboardFilePath, "a")) == NULL) {
         fprintf(stderr, "Unable to create leaderboard file.\n");
         return;
@@ -73,12 +74,12 @@ void leaderboard_record(int Score) {
 
 void marathon_main() {
 
-    // Init Music
+    /* Init Music */
     Mix_Music *Background = Mix_LoadMUS("resources/marathon.wav");
     Mix_PlayMusic(Background, -1);
     Mix_VolumeMusic(GlobalSettings.MusicVolume);
 
-    // Init balls lmao
+    /* Init balls lmao */
     struct Balls Ball;
 	Ball.X = 1280/2.0f;
 	Ball.Y = 720/2.0f;
@@ -87,23 +88,23 @@ void marathon_main() {
 	Ball.Angle = 0.0f;
     Ball.NextTick = SDL_AtomicGet(&Ticks)+1;
 
-    // Init Player
+    /* Init Player */
     struct Players Player;
     Player.Y = 0;
     Player.Direction = 0;
     Player.Score = 0;
 
-    // Init sprites
+    /* Init sprites */
     Texture2D PaddleSprite = LoadTexture("resources/paddle.png");
 	Texture2D BallSprite = LoadTexture("resources/ball.png");
 
-    char PlayerScore[50]; // Used later to display score on screen.
+    char PlayerScore[50]; /* Used later to display score on screen. */
 
-    // Set Collision Boxes
+    /* Set Collision Boxes */
 	Player.HitBox = (Rectangle){80, Player.Y, 5, PaddleSprite.height};
 	Ball.HitBox = (Rectangle){Ball.X, Ball.Y, BallSprite.width, BallSprite.height};
 
-    // Init Camera
+    /* Init Camera */
     Camera2D MainCamera;
         MainCamera.target = (Vector2){0, 0};
         MainCamera.offset = (Vector2){0, 0};
@@ -111,11 +112,11 @@ void marathon_main() {
     bool MarathonGoing = true;
 	bool HasScored = false;
     while(MarathonGoing == true && GameGoing == true) {
-        if (WindowShouldClose()) { //Quit Game if the window is closed.
+        if (WindowShouldClose()) { /* Quit Game if the window is closed. */
             GameGoing = false;
         }
 
-		//Prevents multi-scoring in some cases.
+		/* Prevents multi-scoring in some cases. */
 		if (Ball.Direction == LEFT) {
 			HasScored = true;
 		} else {
@@ -127,7 +128,7 @@ void marathon_main() {
 	    MainCamera.offset = (Vector2){GetScreenWidth()/2.0f, GetScreenHeight()/2.0f};
 	    MainCamera.target = (Vector2){1280/2.0f, 720/2.0f};
 
-       	//Controls
+       	/* Controls */
         if(IsKeyDown(KEY_UP)) {
             Player.Y -= 10;
         } else if (IsKeyDown(KEY_DOWN)) {
@@ -150,19 +151,19 @@ void marathon_main() {
             SetMousePosition(0, 720);
         }
 
-        //Check if players are off-screen
+        /* Check if players are off-screen */
         if (Player.Y < 0) {
             Player.Y = 0;
         } else if (Player.Y > 480) {
             Player.Y = 480;
         }
 
-        // Collision
+        /* Collision */
         ball(&Player.HitBox, NULL, &Ball, &Player.Score, NULL);
-        //Updates hitbox with player's position.
+        /* Updates hitbox with player's position. */
         Player.HitBox.y = Player.Y;
 
-        // End Game
+        /* End Game */
         if(Ball.X < 0) {
             MarathonGoing = false;
         }