Summary


Physics are an important part of games today, but you saw that it is not easy to get even an existing physics engine implemented into an XNA game. But you can still implement physics your own way to make sure that the game runs on the Xbox 360 too, where unmanaged code is not allowed.

There are many topics in physics and it is certainly not easy to implement them all yourself, and even with a good physics engine you still have to do a lot of fine-tuning and testing. However, if you compete with another game that has great physics and uses it in a way that does not destroy the game play or the fun of the game, the other game will be superior if you only have very basic rules. But you should also be aware of the work associated with physics and you can probably guess by this chapter’s length and position in this book that physics is not the easiest topic, especially for beginners. Though this chapter did not cover all possibilities that physics engines might cover you did take a nice tour through available physics engines. If you are interested in reading more about physics, there is a lot of information available both on the Web and in many good books and series of books like the Game Programming Gems.

The Racing Game and the game logic and how everything else is handled in the game is discussed in the next chapter. Other games of this book also used a little bit of physics, but you could get away with ignoring many other issues. For example, the XNA Shooter only handles ship, unit, and projectile movements and handles simple collisions by checking distances. But the game works and that is what counts in the end. In the same manner you only implemented what was necessary for the Racing Game - nothing more, and nothing less.

In this chapter you learned about the following topics, which are all used in the Racing Game:

  • Newton’s Laws of Motion may be old, but they are still useful and allow you to quickly implement simple physics into your game. You also saw that the famous F = m * a formula was used several times and it is the most important formula you need for most physics calculations.

  • Always keep the problems as simple as possible; split them up into smaller problems and write unit tests to figure out what to do next. You also won’t end up implementing any unnecessary code that will not be used later anyway.

  • You learned all about the physics engines that are available today. PhysX and Havok are the major players here, but they are both commercial engines and you can’t just plug them into XNA and expect them to work on your Xbox 360 because they use unmanaged code, which is not supported or even allowed on the Xbox 360 with XNA. Because they cost a lot of money you will probably be better off using one of the free alternatives, which have great samples and tutorials, but suffer from the same lack of .NET support. ODE.NET is a nice solution because a lot of work has already been done, and though it just supports some basic features, it is still a very powerful physics engine that can save you months of work.

  • Then you went step by step through the problems you encounter in a Racing Game like driving through loopings, handling spring physics, and how to handle collision detectionRacing Game. A more complex collision detection system was used in Rocket Commander, but the collisions themselves were pretty simple due the fact that you only checked if the bounding spheres collide.

  • After detecting a collision it must be handled, and when the collision detection is accurate you will spend most of the time tweaking this code to make sure the collision feels real. In the Racing Game I did not have much time to fine-tune a lot, but the basic rules are implemented and it should be possible for anyone that is interested to improve the game and maybe add more physics collisions and calculations.

In Chapter 14, the last chapter in this book, you learn all about the Racing Game and how to create modifications, which will be pretty exciting.




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