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 RemoveBulletAtIndex(int index);
|
||||
void RemoveEnemyAtIndex(int index);
|
||||
void InitializeEnemies();
|
||||
void CheckEnemies();
|
||||
void MoveEnemies();
|
||||
void LimitEnemies();
|
||||
|
@ -130,6 +129,7 @@ float VectorDistanceBetween(Vector2D vectorFirst, Vector2D vectorSecond);
|
|||
byte isVectorExceedingLimits(Vector2D vector, Vector2D limits);
|
||||
byte CheckCollision(Vector2D *firstPos, Vector2D *secondPos, Image *firstMap, Image *secondMap);
|
||||
|
||||
char InitializeEnemies();
|
||||
char InitializeGameWindow();
|
||||
char InitializeGame();
|
||||
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 = al_load_sample(bgmSoundPath);
|
||||
|
||||
if(BGM == NULL)
|
||||
return 0;
|
||||
|
||||
al_play_sample(BGM, 1.0, 0.0, 1.0, ALLEGRO_PLAYMODE_LOOP, NULL);
|
||||
return 1;
|
||||
}
|
||||
|
||||
char InitializeGame()
|
||||
|
@ -451,7 +456,11 @@ char InitializeGame()
|
|||
shootSound = al_load_sample(shootSoundPath);
|
||||
enemyDieSound = al_load_sample(dieSoundPath);
|
||||
|
||||
InitializeEnemies();
|
||||
if(shootSound == NULL || enemyDieSound == NULL)
|
||||
return 0;
|
||||
|
||||
if(!InitializeEnemies())
|
||||
return 0;
|
||||
GetHighScore();
|
||||
|
||||
/* Player Initialization */
|
||||
|
@ -480,7 +489,7 @@ char InitializeGame()
|
|||
return 1;
|
||||
}
|
||||
|
||||
void InitializeEnemies()
|
||||
char InitializeEnemies()
|
||||
{
|
||||
enemies.enemyLimit = initialEnemyLimit;
|
||||
enemies.enemyCount = 0;
|
||||
|
@ -491,7 +500,14 @@ void InitializeEnemies()
|
|||
enemyBulletImage = InitImage(bulletImagePath);
|
||||
gameOverImage = InitImage(gameOverImagePath);
|
||||
|
||||
if( enemyImage.bitmap == NULL ||
|
||||
numberTable.bitmap == NULL ||
|
||||
enemyBulletImage.bitmap == NULL ||
|
||||
gameOverImage.bitmap == NULL )
|
||||
return 0;
|
||||
|
||||
SpawnEnemies();
|
||||
return 1;
|
||||
}
|
||||
|
||||
void SpawnEnemies()
|
||||
|
|
Loading…
Reference in New Issue