Purpose
The purpose of this application is first and foremost to entertain the user. It is built in the style of a retro arcade game which is conducive to replay-ability and allows for the user to compete against his or her friends for the highest score.
How to play
In the style of many arcade games the controls have been kept basic to allow for the user to pick them up quickly and master them over time. The left and right arrow keys are used for turret rotation, space to fire and P to toggle pause. The game ends when your shots remaining reaches zero and all shots are off-screen.
Modifications from the original assignment
This game has been modified in several ways to change certain aspects of how gameplay develops. First, you have a larger initial number of shots to fire, however the number of shots on screen at any given point has been limited to 5 and an indicator has been added in the bottom left corner stating the number of shots remaining as well as the number of shots on screen in comparison to the number allowed. Second, the planes give varying point amounts based on their speeds, which have been randomized within a range. The faster a plane is moving the harder it is to hit (as a result, the more luck is involved when landing a hit) and the higher the number of points is. Third, an advanced hit test library has been used to increase the accuracy of shot-plane collisions, now instead of using the bounding box for hit tests (which hitTestObject uses) we uses matrices to calculate pixel-level collisions. Fourth, easter eggs! Yes, I added an easer egg into the game, see if you can find it. Fifth, I limited the number of planes on screen at any given time to 2 in hopes of minimizing game lag.
The math of the game
The majority of the math used in this game with hit detection between the planes and bullets, which uses matrices and pixel opacity to determine if two or more objects collide each frame. If they do a collision function is called and we remove the two objects as well as increment the score as needed. Other math in use includes simple trig to determine rotation of the turret as well as the bullets and their flight path. All the rest is simple algebra including adding numbers together, and in some cases multiplying them.