An Asteroids programming question
Posted: Fri Oct 26, 2007 1:38 am
This can be pseudo-cody, so it's out there for anyone.
OK, imagine if you will an Asteroids game where all the Asteroids are squares and they don't rotate. We're also using vectors.
It is easy to determine if a bullet his the asteroid, because you can easily determine the size of the asteroid by simply knowing it's upper-left-hand position and whether it's a big, medium or small asteroid. If the bullet is drawn inside the area an asteroid must encompass, then run the routine (or jump to the area in the code) where the asteroid breaks up.
But how do you solve this for asteroids that are not square chunks? You can cheat by assigning it square space anyway. But eventually that's going to look like shit and the player will notice.
Does anyone recall or know how this collision-detection-based problem is (well... was, let's be honest) generally solved in 2D games?
OK, imagine if you will an Asteroids game where all the Asteroids are squares and they don't rotate. We're also using vectors.
It is easy to determine if a bullet his the asteroid, because you can easily determine the size of the asteroid by simply knowing it's upper-left-hand position and whether it's a big, medium or small asteroid. If the bullet is drawn inside the area an asteroid must encompass, then run the routine (or jump to the area in the code) where the asteroid breaks up.
But how do you solve this for asteroids that are not square chunks? You can cheat by assigning it square space anyway. But eventually that's going to look like shit and the player will notice.
Does anyone recall or know how this collision-detection-based problem is (well... was, let's be honest) generally solved in 2D games?