Added The Missing NULL Checks
This commit is contained in:
parent
5596b53c02
commit
f9e795e5e4
22
SynGame.c
22
SynGame.c
|
@ -95,7 +95,6 @@ void SpawnEnemies();
|
||||||
void CheckBullets();
|
void CheckBullets();
|
||||||
void RemoveBulletAtIndex(int index);
|
void RemoveBulletAtIndex(int index);
|
||||||
void RemoveEnemyAtIndex(int index);
|
void RemoveEnemyAtIndex(int index);
|
||||||
void InitializeEnemies();
|
|
||||||
void CheckEnemies();
|
void CheckEnemies();
|
||||||
void MoveEnemies();
|
void MoveEnemies();
|
||||||
void LimitEnemies();
|
void LimitEnemies();
|
||||||
|
@ -130,6 +129,7 @@ float VectorDistanceBetween(Vector2D vectorFirst, Vector2D vectorSecond);
|
||||||
byte isVectorExceedingLimits(Vector2D vector, Vector2D limits);
|
byte isVectorExceedingLimits(Vector2D vector, Vector2D limits);
|
||||||
byte CheckCollision(Vector2D *firstPos, Vector2D *secondPos, Image *firstMap, Image *secondMap);
|
byte CheckCollision(Vector2D *firstPos, Vector2D *secondPos, Image *firstMap, Image *secondMap);
|
||||||
|
|
||||||
|
char InitializeEnemies();
|
||||||
char InitializeGameWindow();
|
char InitializeGameWindow();
|
||||||
char InitializeGame();
|
char InitializeGame();
|
||||||
char DealDamage(char *health);
|
char DealDamage(char *health);
|
||||||
|
@ -443,7 +443,12 @@ char InitializeGameWindow()
|
||||||
|
|
||||||
/* BGM is an exception since I don't want to it to restart itself every restart */
|
/* BGM is an exception since I don't want to it to restart itself every restart */
|
||||||
BGM = al_load_sample(bgmSoundPath);
|
BGM = al_load_sample(bgmSoundPath);
|
||||||
|
|
||||||
|
if(BGM == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
al_play_sample(BGM, 1.0, 0.0, 1.0, ALLEGRO_PLAYMODE_LOOP, NULL);
|
al_play_sample(BGM, 1.0, 0.0, 1.0, ALLEGRO_PLAYMODE_LOOP, NULL);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
char InitializeGame()
|
char InitializeGame()
|
||||||
|
@ -451,7 +456,11 @@ char InitializeGame()
|
||||||
shootSound = al_load_sample(shootSoundPath);
|
shootSound = al_load_sample(shootSoundPath);
|
||||||
enemyDieSound = al_load_sample(dieSoundPath);
|
enemyDieSound = al_load_sample(dieSoundPath);
|
||||||
|
|
||||||
InitializeEnemies();
|
if(shootSound == NULL || enemyDieSound == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if(!InitializeEnemies())
|
||||||
|
return 0;
|
||||||
GetHighScore();
|
GetHighScore();
|
||||||
|
|
||||||
/* Player Initialization */
|
/* Player Initialization */
|
||||||
|
@ -480,7 +489,7 @@ char InitializeGame()
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitializeEnemies()
|
char InitializeEnemies()
|
||||||
{
|
{
|
||||||
enemies.enemyLimit = initialEnemyLimit;
|
enemies.enemyLimit = initialEnemyLimit;
|
||||||
enemies.enemyCount = 0;
|
enemies.enemyCount = 0;
|
||||||
|
@ -491,7 +500,14 @@ void InitializeEnemies()
|
||||||
enemyBulletImage = InitImage(bulletImagePath);
|
enemyBulletImage = InitImage(bulletImagePath);
|
||||||
gameOverImage = InitImage(gameOverImagePath);
|
gameOverImage = InitImage(gameOverImagePath);
|
||||||
|
|
||||||
|
if( enemyImage.bitmap == NULL ||
|
||||||
|
numberTable.bitmap == NULL ||
|
||||||
|
enemyBulletImage.bitmap == NULL ||
|
||||||
|
gameOverImage.bitmap == NULL )
|
||||||
|
return 0;
|
||||||
|
|
||||||
SpawnEnemies();
|
SpawnEnemies();
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpawnEnemies()
|
void SpawnEnemies()
|
||||||
|
|
Loading…
Reference in New Issue