Lesson 21: A Sample Game: Crab Pong
- Summary
- *
- Text version
- *
- Exercises
- *
- Download source
The exercises are sorted roughly from easiest to hardest.
- Add some specularity to the text for the scores.
- Change the farthest visible z coordinate from 5 to 20 in handleResize. Make the camera angle shallower, so that you can see the horizon. Add fog to the scene, so that the water in the distance looks grayer. The fog may be applied just to the water or to the entire scene.
- Change the farthest visible z coordinate from 5 to 20 in handleResize. Make the camera angle shallower, so that you can see the horizon, and make the water texture mipmapped, so that the water looks better in the distance.
- Make the barriers partially transparent. When doing the alpha blending, use backface culling rather than sorting the polygons from back to front. You may remove their shininess.
- Make one display list that draws the sand, the barriers, and the poles, and use it to draw them. The display list may call other display lists, and it should change when a pole is added to or removed from play.
- Disable GL_NORMALIZE when drawing the crab models, without adding a call to the Vec3f class's normalize() method, which would nullify any speed gains. In order to do this, you will want to change the normal vector at a given instant to be the normal at a particular frame rather than the average of the normals at two frames. Although this worsens the appearance of the crab, in this case, the difference isn't noticeable. Note that the predetermined normals given in the array NORMALS all have a magnitude of 1.
- Add a 1 x 1 mirror behind the playing field (i.e. past the orange crab).
- Change the game into 1N54n3 cR4B P0nG!!!!1!1!111! Remove the limit on the number of balls. Decrease the fade in time and fade out time for the balls to 0.005. Decrease the radius of the balls to 0.01. Decrease the speed of the balls to 0.5. Increase the starting score to 100. You need not change any of the step time constants. Use a quadtree to speed up collision detection.
- Make the water into a repetition of a terrain using this heightmap. The water should still move forward, and it should still have the same texture applied to it. Each repetition of the terrain should be 0.3 x 0.3, but each repetition of the texture should still be WATER_TEXTURE_SIZE x WATER_TEXTURE_SIZE. You need only use as many repetitions of the terrain as are visible from the viewing angle. Make drawing the water fast by using at least one display list.
- Add fireworks that are shot off when the player wins, using a particle system.