Challenge: Write a Free Camera Class


You already learned everything there is to know to handle input devices. Optional input devices like an Xbox 360 Wheel Controller are supported automatically as a gamepad in the Input class. You could, for example, play Rocket Commander XNA with an Xbox Wheel Controller if you like. It will be unnatural, but it works and it looks funny.

You also have a lot of game screens classes and you will try to reuse them for the next games. The XNA Shooter game, for example, uses almost the same menu structure as Rocket Commander XNA, just more simplified. In the next chapter you learn more about the XNA Shooter game.

Your task for this chapter is to write your own free camera class. You could implement a free camera in 3D space, allowing you to move to any direction you want. Just exchange the SimpleCamera class in BaseGame and replace it with your camera class; then you can test all unit tests that show 3D data to test out your camera. If you are unsure about how to start, check out the existing code in the SpaceCamera class, which provides most functionality for this kind of camera handling.

Alternatively, you could implement a shooter camera, which also allows you to freely rotate and move around, but you stay on the ground. You could even improve this camera and do simple collision tests with the ground allowing you to go up or down when the underground allows it. If you want to do this I recommend that you write a unit test that shows some objects and a ground plane first to test out your camera class.




Professional XNA Game Programming
Professional XNA Programming: Building Games for Xbox 360 and Windows with XNA Game Studio 2.0
ISBN: 0470261285
EAN: 2147483647
Year: 2007
Pages: 138

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net