[Asteroid Hell] live
A copy of Asteroids inspired by bullet-hell games.
Asteroids spawn randomly at the edges of the screen, and must be destroyed. Luckily, you recieve money for each small asteroid, and so can afford to upgrade your ship. Unfortunately, the more money you make the faster they spawn. In the long run, we are all dead.
#Screen Shots
[] live
[] live
[] live
The Asteroids are randomly generated polygons. Depending on the size, each has between eight and twenty vertices. These are generated by computing random angles, which are converted into vectors. Initially these are all the same length (the radius of the asteroid), but 40 percent are then scaled down by a factor of 0.8.
Each object has a center, a radius, and a collection of vertices. Collisions are first ruled out using the first two. Objects within-radii of each other are then compared using a simplified version of the Separating Axis Theorem. Clearly collisions between asteroids and the ship, or asteroids and projectiles result in the destruction of objects. Collisions between asteroids result in a billiard-style bouncing if they are moving toward each other, or no interaction if they are moving apart. This allows asteroids that spawn on top of each other a chance to move apart before they start bouncing.
The upgrades menu is activated when the game is paused. They html for it is generated at runtime using jQuery from an object defining the various upgrades available. This object keeps track of which items the player has bought, and therefore which can be equipped. Equipping items adds them to an object on the ship class.