| Homework 16General CommentsHomework assignments will be drawn from a variety of sources. For programs, make sure you commit your solution to SVN by the assignment deadline!DetailsImplement Asteroids
Go to the course directory to 342/solutions/Asteroids.exe to see an example of a "B"-level solution to the assignment. Use A and D to turn left/right, W to go speed up, S to slow down, and space to fire.
You will notice that this solution has the following features:
- The ship can turn, move, and fire
- The asteroids spin around.
- The asteroids move.
- The asteroids disappear when hit by the laser (or photon beam or whatever it is).
- The ship is disabled temporarily if an asteroid hits it.
- When something hits any edge of the screen, it reappears on the opposite edge of the screen.
A solution that is well-implemented and does essentially all of these things will earn a grade of a "B". A project that falls short of the example
project and/or that is poorly implemented may receive a lower grade.
To earn an "A", you need to add more features to the game.
Possible features to add:
- Have large asteroids break into 3 smaller asteroids when they are hit. These three pieces should probably break off and travel in three different directions, perhaps 120 degrees apart. Small asteroids just disappear. Maybe the smaller ones are faster than the bigger ones.
- Have asteroids bounce off each other when they collide and/or break into pieces as if they were hit.
- Implement a shield for the ship so that when a certain key is pressed, asteroids bounce off. There should be a time limit (e.g. 1 second) that the shield can be active, and a cool down period (e.g. 10 seconds) during which the shield cannot be used.
- Implement alien ship(s) that fire your ship, either intelligently (although perhaps not perfectly) or randomly.
- Have the arena split into 4 quadrants. When the ship goes to the end of the screen instead of just wrapping around in the same quadrant, it wraps to the next quadrant (still jumping over to the other side of the screen, but it is now in a different quadrant). If it continues to the end of the screen again, it goes back to the first quadrant. In other words, the arena is a 2x2 grid that wraps around, with the ship being in one quadrant at a time. Instead of having the quadrants wrapping, you could have boundaries on the outside edges. Or you could have boundaries for the ship, but allow the asteroids to wrap around. In any case, you should include on the screen a "map" of the 4 quadrants in a smaller view so the player can see where they are and what is in all of the quadrants right now. In other words, draw a small version of the whole arena somewhere, and then draw just one quadrant in the main screen area. (If you use the appropriate concepts we have learned about, this shouldn't be too difficult.)
You may suggest your own features as well, but make sure you clear them with me to make sure they are significant enough (and related to the graphics part of the project enough) to merit an "A" grade.
Here are a few hints/tips:
- Don't just sit down and program. Think through all of the features you want and think about what classes and/or methods will help you to implement your solution, preferably in a step-by-step fashion. That is, get one feature to work at a time instead of trying to get it all work at the same time.
A proper design will allow you to do this very easily.
- Think in particular about what methods you might want to add to existing classes (e.g. might you want to use PolyLine and/or
PolylineCollection to store game elements? If so, what methods might be useful to add to those classes to facilitate various things.
- Should you have a class for game elements? What fields would it have?
- Where/how will you do collision detection? Do you need different algorithms for the laser hitting asteroids and the ship and/or other asteroids hitting asteroids?
- Since objects are moving and spinning, how will you store the locations and rotations? OpenGL will automatically translate and rotate for you if you store an offset and an angle for each object and apply the appropriate transformations. However, for collision detection you will need to re-compote the actual locations of vertices.
|