Sorted the assets into folders and created Makefile.

This commit is contained in:
Michael Chen 2017-12-27 00:29:20 +01:00
parent bc9f0a7aa2
commit 14a2bd131f
4 changed files with 11 additions and 9 deletions

2
Makefile Normal file
View File

@ -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

View File

@ -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");

2
main.c
View File

@ -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};

View File

@ -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));