Skip to content

Commit

Permalink
Fix some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewL246 committed Nov 26, 2023
1 parent d145a2c commit 1bb7682
Show file tree
Hide file tree
Showing 13 changed files with 58 additions and 67 deletions.
8 changes: 4 additions & 4 deletions source/bullet.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <malloc.h>
#include <math.h>

#include "bullet.h"

#include "drawing.h"
#include <malloc.h>
#include <math.h>

Bullet *bulletsHead = NULL;
Bullet *bulletsTail = NULL;
Expand Down Expand Up @@ -53,7 +53,7 @@ void RemoveBullet(Bullet *bullet)
free(bullet);
}

void MoveAllBullets()
void MoveAllBullets(void)
{
Bullet *currentBullet = bulletsHead;

Expand Down
7 changes: 2 additions & 5 deletions source/bullet.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef BULLET_H
#define BULLET_H
#pragma once

#include "structs.h"
#include "tower.h"
Expand All @@ -22,6 +21,4 @@ void AddBullet(Tower *fromTower);

void RemoveBullet(Bullet *bullet);

void MoveAllBullets();

#endif
void MoveAllBullets(void);
16 changes: 8 additions & 8 deletions source/drawing.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include <coreinit/screen.h>
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include "drawing.h"

#include "bullet.h"
#include "drawing.h"
#include "enemy.h"
#include "tower.h"
#include <coreinit/screen.h>
#include <math.h>
#include <stdbool.h>
#include <stdio.h>

const int DRC_TOUCH_TOP = 3900;
const int DRC_TOUCH_BOTTOM = 180;
Expand Down Expand Up @@ -54,7 +54,7 @@ void DrawPoint(Point point, Color color, int size, bool drawOnBothScreens)
}
}

void DrawAllTowers()
void DrawAllTowers(void)
{
Tower *currentTower = towersHead;

Expand All @@ -69,7 +69,7 @@ void DrawAllTowers()
}
}

void DrawAllBullets()
void DrawAllBullets(void)
{
Bullet *currentBullet = bulletsHead;

Expand All @@ -80,7 +80,7 @@ void DrawAllBullets()
}
}

void DrawAllEnemies()
void DrawAllEnemies(void)
{
Enemy *currentEnemy = enemiesHead;

Expand Down
14 changes: 5 additions & 9 deletions source/drawing.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
#ifndef DRAWING_H
#define DRAWING_H

#include <stdbool.h>
#pragma once

#include "structs.h"
#include <coreinit/time.h>
#include <stdbool.h>

#define DRC_SCREEN_WIDTH 854
#define DRC_SCREEN_HEIGHT 480
Expand All @@ -13,10 +11,8 @@ Point MapTouchToDrcScreen(int touchX, int touchY);

void DrawPoint(Point point, Color color, int size, bool drawOnBothScreens);

void DrawAllTowers();

void DrawAllBullets();
void DrawAllTowers(void);

void DrawAllEnemies();
void DrawAllBullets(void);

#endif
void DrawAllEnemies(void);
8 changes: 4 additions & 4 deletions source/enemy.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include <malloc.h>
#include "enemy.h"

#include "drawing.h"
#include "enemy.h"
#include <malloc.h>

Enemy *enemiesHead = NULL;
Enemy *enemiesTail = NULL;

void AddEnemy()
void AddEnemy(void)
{
Enemy *newEnemy = malloc(sizeof(Enemy));
newEnemy->position = (Point){0, DRC_SCREEN_HEIGHT / 2};
Expand Down Expand Up @@ -55,7 +55,7 @@ void RemoveEnemy(Enemy *enemy)
free(enemy);
}

void MoveAllEnemies()
void MoveAllEnemies(void)
{
Enemy *currentEnemy = enemiesHead;

Expand Down
9 changes: 3 additions & 6 deletions source/enemy.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef ENEMY_H
#define ENEMY_H
#pragma once

#include "structs.h"

Expand All @@ -16,10 +15,8 @@ typedef struct Enemy

extern Enemy *enemiesHead;

void AddEnemy();
void AddEnemy(void);

void RemoveEnemy(Enemy *enemy);

void MoveAllEnemies();

#endif
void MoveAllEnemies(void);
21 changes: 11 additions & 10 deletions source/game.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#include "game.h"

#include "bullet.h"
#include "drawing.h"
#include "enemy.h"
#include "structs.h"
#include "tower.h"
#include <coreinit/screen.h>
#include <coreinit/time.h>
#include <malloc.h>
Expand All @@ -8,13 +15,7 @@
#include <vpad/input.h>
#include <whb/log.h>

#include "bullet.h"
#include "drawing.h"
#include "enemy.h"
#include "structs.h"
#include "tower.h"

void CheckBulletEnemyCollisions()
void CheckBulletEnemyCollisions(void)
{
Bullet *currentBullet = bulletsHead;

Expand Down Expand Up @@ -98,7 +99,7 @@ int GameLoop(VPADStatus status, OSTick deltaTime)
return 0;
}

void GameShutdown()
void GameShutdown(void)
{
// Free all towers, bullets, and enemies
while (towersHead)
Expand All @@ -118,7 +119,7 @@ void GameShutdown()
int profilerMessageCounter = 0;
OSTick fromTime = 0;

void ProfilerStartFrame()
void ProfilerStartFrame(void)
{
profilerMessageCounter = 0;
fromTime = OSGetTick();
Expand All @@ -128,7 +129,7 @@ void ProfilerLogTime(char *title, OSTick time)
{
unsigned frametimeMicroseconds = OSTicksToMicroseconds(time);
char profilerLogString[100];
snprintf(profilerLogString, 100, "%s: %.2f ms", title, frametimeMicroseconds / 1000.0);
snprintf(profilerLogString, sizeof(profilerLogString), "%s: %.2f ms", title, frametimeMicroseconds / 1000.0);
OSScreenPutFontEx(SCREEN_DRC, 0, profilerMessageCounter, profilerLogString);
OSScreenPutFontEx(SCREEN_TV, 0, profilerMessageCounter, profilerLogString);
profilerMessageCounter++;
Expand Down
9 changes: 7 additions & 2 deletions source/game.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#pragma once

#include <coreinit/time.h>
#include <vpad/input.h>

int GameLoop(VPADStatus status, OSTick deltaTime);

void GameShutdown();
void GameShutdown(void);

void ProfilerStartFrame();
void ProfilerStartFrame(void);

void ProfilerLog(char *title);

Expand Down
10 changes: 5 additions & 5 deletions source/main.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include <malloc.h>
#include <stdbool.h>
#include <stdio.h>
#include <math.h>
#include <coreinit/time.h>
#include <coreinit/cache.h>
#include <coreinit/screen.h>
#include <coreinit/thread.h>
#include <coreinit/time.h>
#include <malloc.h>
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <vpad/input.h>
#include <whb/log.h>
#include <whb/log_cafe.h>
Expand Down
4 changes: 2 additions & 2 deletions source/structs.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <stdbool.h>

#include "structs.h"

#include <stdbool.h>

bool PointEquals(Point a, Point b)
{
return a.x == b.x && a.y == b.y;
Expand Down
5 changes: 1 addition & 4 deletions source/structs.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef STRUCTS_H
#define STRUCTS_H
#pragma once

#include <stdbool.h>

Expand Down Expand Up @@ -27,5 +26,3 @@ typedef struct Color
} Color;

bool ColorEquals(Color a, Color b);

#endif
6 changes: 3 additions & 3 deletions source/tower.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <malloc.h>
#include <math.h>
#include "tower.h"

#include "bullet.h"
#include "tower.h"
#include <malloc.h>
#include <math.h>

Tower *towersHead = NULL;
Tower *towersTail = NULL;
Expand Down
8 changes: 3 additions & 5 deletions source/tower.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#ifndef TOWER_H
#define TOWER_H
#pragma once

#include "structs.h"

#define INVALID_TOWER_TARGET (Point){-1, -1}
#define INVALID_TOWER_TARGET \
(Point) { -1, -1 }

typedef struct Bullet Bullet;

Expand All @@ -28,5 +28,3 @@ void RemoveTower(Tower *tower);
void SetLastTowerTarget(Point targetPosition);

void FireAllTowers(unsigned gameLoopCounter);

#endif

0 comments on commit 1bb7682

Please sign in to comment.