Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualLudus

Posted 01 April 2013 - 12:38 AM

As others have mentioned, there are many ways to optimize collision detection. Which methods you can deploy depend on the mechanics of the game itself. Someone already brought up how lasers don't collide with other lasers. But what about enemies colliding with other enemies? From what I understand, you're creating a top-down space shoot em' up. In many games like this (and in many retro games in general) enemies don't collide with other enemies - they simply overlap and pass through each other. Because of this, enemies don't need to check for collision against other enemies. Also, will your game have power-ups you can collect? It should go without saying that these objects only need to check for collision against the player.

 

Someone mentioned spatial partitioning. For the type of game you're creating this is overkill. The most common method of keeping collision checks to a minimum in a top-down space shoot em' up is to create the enemies' objects during play as the player approaches where they should appear (as opposed to creating all the enemies at once when the level loads). You will also need to destroy the objects as they leave the screen. This is also a common method in retro 2D platformers and it's effects are easy to observe: have you ever wondered why enemies tend disappear when they move off screen, only to reappear at their starting point? This is why. Using this method of creating and destroying objects as needed also serves another purpose - enemies off screen will not be rendered or have their logic updated each frame, thus saving a lot of processing.


#1Ludus

Posted 31 March 2013 - 11:08 PM

As other have mentioned, there are many ways to optimize collision detection. Many of these methods depend on the mechanics of the game itself. Someone already brought up how lasers don't collide with other lasers. But what about enemies colliding with other enemies? From what I understand, you're creating a top-down space shoot em' up. In many games like this (and in many retro games in general) enemies don't collide with other enemies - they simply overlap and pass through each other. Because of this, enemies don't need to check for collision against other enemies. Also, will your game have power-ups you can collect? It should go without saying that these objects only need to check for collision against the player.

 

Someone mentioned spatial partitioning. For the type of game you're creating this is overkill. The most common method of keeping collision checks to a minimum in a top-down space shoot em' up is to create the enemies' objects during play as the player approaches where they should appear (as opposed to creating all the enemies at once when the level loads). You will also need to destroy the objects as they leave the screen. This is also a common method in retro 2D platformers and it's effects are easy to observe: have you ever wondered why enemies tend disappear when they move off screen, only to reappear at their starting point? This is why. Using this method of creating and destroying objects as needed also serves another purpose - enemies off screen will not be rendered or have their logic updated each frame, thus saving a lot of processing.


PARTNERS