CollisionDetectionTest/EnemyBullets.c
/* Handles the functions that happen when the ball hits a bullet */
Handles the functions that happen when the ball hits a bullet
Handles the functions that happen when the ball hits a bullet
void Ball_Bullet_Collision(int x_pos, int y_pos, TileMapManager *tileManager, Sound *sound, EnemyBullet *enemyBullet[])
{
	int i;	
	for (i = 0; i < 50; ++i)
	{
		if (enemyBullet[i] != NULL)
		{
			if (x_pos == enemyBullet[i]->x_Pos && y_pos == enemyBullet[i]->y_Pos)
			{
				TileMapManager_EnemyBullet(enemyBullet[i], tileManager, 0);
				WorldData_GoToXY(enemyBullet[i]->x_Pos, enemyBullet[i]->y_Pos);
				printf(" ");
				EnemyBullet_Free(&enemyBullet[i]);
				loadSound(sound, "..\\CollisionDetectionTest\\SFX\\BallDestroyBullet.wav");
				playSound_Low(sound);
				break;
			}
		}
	}
}
void Ball_Bullet_Collision ( int x_pos , int y_pos , TileMapManager * tileManager , Sound * sound , EnemyBullet * enemyBullet [ ] ) { int i ; for ( i = 0 ; i < 50 ; ++ i ) { if ( enemyBullet [ i ] != NULL ) { if ( x_pos == enemyBullet [ i ] -> x_Pos && y_pos == enemyBullet [ i ] -> y_Pos ) { TileMapManager_EnemyBullet ( enemyBullet [ i ] , tileManager , 0 ) ; WorldData_GoToXY ( enemyBullet [ i ] -> x_Pos , enemyBullet [ i ] -> y_Pos ) ; printf ( " " ) ; EnemyBullet_Free ( & enemyBullet [ i ] ) ; loadSound ( sound , " \\ \\ \\ " ) ; playSound_Low ( sound ) ; break ; } } } }
Handles the functions that happen when the ball hits a bullet
Handles the functions that happen when the ball hits a bullet
/* Loop counter */ /* Finds bullet that exists */ /* If bullet exists */ /* If position matches with the ball it is colliding with */ /* Removes the bullet from the game */