Original Post
Hey, I was wondering about a good approach for testing collisions between bullets and enemy/player.
Currently, anytime the player fires, a new bullet object is added to a list of active Bullets. If the list size > 0 then it loops through each bullet. First I have a BSP check, to see if its in the same sector as the enemy. Then I have a rectangle test, and then per pixel.
But I would also like to be able to hit the player with enemy bullets.
What is the best way to do this?
Should I just add the enemies bullets to the same active Bullets list? Or since there is only 1 player, should I put directly in the update() method of the bullet class.(Everytime a bullet is updated, it checks if it is in same sector as player, then rectangle and perpixel).
Or should I have 2 separate lists for enemies and player?
Also, the way I am checking for collisions with the enemy(because there is more than 1) is looping through each active bullet, and then looping through an enemy that it may collide with. Is this how it normally goes? With a double for loop?
Currently, anytime the player fires, a new bullet object is added to a list of active Bullets. If the list size > 0 then it loops through each bullet. First I have a BSP check, to see if its in the same sector as the enemy. Then I have a rectangle test, and then per pixel.
But I would also like to be able to hit the player with enemy bullets.
What is the best way to do this?
Should I just add the enemies bullets to the same active Bullets list? Or since there is only 1 player, should I put directly in the update() method of the bullet class.(Everytime a bullet is updated, it checks if it is in same sector as player, then rectangle and perpixel).
Or should I have 2 separate lists for enemies and player?
Also, the way I am checking for collisions with the enemy(because there is more than 1) is looping through each active bullet, and then looping through an enemy that it may collide with. Is this how it normally goes? With a double for loop?