From 14a2bd131f53a15f76bc688950f7afb4708526f4 Mon Sep 17 00:00:00 2001 From: Michael Chen Date: Wed, 27 Dec 2017 00:29:20 +0100 Subject: [PATCH] Sorted the assets into folders and created Makefile. --- Makefile | 2 ++ asteroids.c | 14 +++++++------- main.c | 2 +- starfield.c | 2 +- 4 files changed, 11 insertions(+), 9 deletions(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..94369ca --- /dev/null +++ b/Makefile @@ -0,0 +1,2 @@ +all: + gcc -Wall -IC:\SDL2\x32\include *.c -LC:\SDL2\x32\lib -lmingw32 -lSDL2main -lSDL2 -lopengl32 -lSDL2_image -lSDL2_ttf -o Asteroids.exe diff --git a/asteroids.c b/asteroids.c index 5aab8a7..d0120ea 100644 --- a/asteroids.c +++ b/asteroids.c @@ -62,9 +62,9 @@ void BULLET_Initialize(SDL_Renderer * renderer, int width, int height){ }; // Default or null bullet BULLET_BoxWidth = width; BULLET_BoxHeight = height; - BULLET_Texture_Ally = IMG_LoadTexture(renderer, "bullet.png"); + BULLET_Texture_Ally = IMG_LoadTexture(renderer, "assets/images/bullet.png"); if (!BULLET_Texture_Ally) printf("Ally bullet texture cannot be loaded!\n"); - BULLET_Texture_Enemy = IMG_LoadTexture(renderer, "enemyBullet.png"); + BULLET_Texture_Enemy = IMG_LoadTexture(renderer, "assets/images/enemyBullet.png"); if (!BULLET_Texture_Enemy) printf("Enemy bullet texture cannot be loaded!\n"); printf("Bullet initialized!\n"); } @@ -159,7 +159,7 @@ void ASTEROID_Initialize(SDL_Renderer * renderer, int width, int height){ printf("Initializing Asteroid...\n"); ASTEROID_BoxWidth = width; ASTEROID_BoxHeight = height; - ASTEROID_Texture = IMG_LoadTexture(renderer, "asteroid.png"); + ASTEROID_Texture = IMG_LoadTexture(renderer, "assets/images/asteroid.png"); ASTEROIDULLET = (Asteroid) { .Rotation = 0.0f, .Size = 0.0f, @@ -291,7 +291,7 @@ void ENEMY_Initialize(SDL_Renderer * renderer, int width, int height){ BULLET_Initialize(renderer, width, height); ENEMY_BoxWidth = width; ENEMY_BoxHeight = height; - ENEMY_Texture = IMG_LoadTexture(renderer, "enemy.png"); + ENEMY_Texture = IMG_LoadTexture(renderer, "assets/images/enemy.png"); if (!ENEMY_Texture) printf("Enemy texture cannot be loaded!\n"); ENEMY_MaxBulletCount = ((BULLET_DecayTime_Ally / ENEMY_ShootIntevale) + 10); printf("Enemy initialized!\n"); @@ -380,11 +380,11 @@ void SHIP_Initialize(SDL_Renderer * renderer, int width, int height){ BULLET_Initialize(renderer, width, height); SHIP_BoxWidth = width; SHIP_BoxHeight = height; - SHIP_Texture_Gliding = IMG_LoadTexture(renderer, "ship.png"); + SHIP_Texture_Gliding = IMG_LoadTexture(renderer, "assets/images/ship.png"); if (!SHIP_Texture_Gliding) printf("Ship texture 1 cannot be loaded!\n"); - SHIP_Texture_Accelerating = IMG_LoadTexture(renderer, "shipAcc.png"); + SHIP_Texture_Accelerating = IMG_LoadTexture(renderer, "assets/images/shipAcc.png"); if (!SHIP_Texture_Accelerating) printf("Ship texture 2 cannot be loaded!\n"); - SHIP_Texture_Explosion = IMG_LoadTexture(renderer, "shipExpl.png"); + SHIP_Texture_Explosion = IMG_LoadTexture(renderer, "assets/images/shipExpl.png"); if (!SHIP_Texture_Explosion) printf("Ship texture explosion cannot be loaded!\n"); SHIP_SourceRect_Explosion = calloc(5, sizeof(SDL_Rect)); if (!SHIP_SourceRect_Explosion) printf("Memory for SDL_Rect (SHIP) cannot be allocated!\n"); diff --git a/main.c b/main.c index 4b740f6..977325b 100644 --- a/main.c +++ b/main.c @@ -116,7 +116,7 @@ void INITIALIZE() { else printf("IMG was successfully initialized!\n"); TTF_Init(); - Sans = TTF_OpenFont("bulky.ttf", 12); + Sans = TTF_OpenFont("assets/fonts/bulky.ttf", 12); if (!Sans) printf("Font cannot be initialized!\n"); else printf("Font was successfully initialized!\n"); messageColor = (SDL_Color) {.r = 125,.g=255,.b = 125,.a = 255}; diff --git a/starfield.c b/starfield.c index 03abc9d..3a4723b 100644 --- a/starfield.c +++ b/starfield.c @@ -22,7 +22,7 @@ void STARFIELD_Initialize(SDL_Renderer * renderer, int width, int height){ printf("Initializing starfield...\n"); STARFIELD_BoxWidth = width; STARFIELD_BoxHeight = height; - STAR_Texture = IMG_LoadTexture(renderer, "star.png"); + STAR_Texture = IMG_LoadTexture(renderer, "assets/images/star.png"); if (!STAR_Texture) printf("Star texture cannot be loaded!\n"); STAR_SourceRects = malloc(3 * sizeof(SDL_Rect));