|
YOUR FEEDBACK
|
TOP MICROSOFT .NET LINKS Feature XNA or Game Development for Everyone - Part 2
Restructuring the game
By: Berndt Hamboeck
Jun. 13, 2008 12:30 PM
In Part 1 of this article, we started to develop a small racing game using XNA Game Studio Express 2.0. We learned about the game loop and how it’s implemented by the XNA (by using the Update and Draw methods) framework. We also created our first track on the screen and four cars started moving on the screen, but, sadly enough, they left the track and weren’t seen again. What does that mean? It means we should take a closer look at collision detection. In addition we should design a menu with different options. You might remember that we want to have a racing game with three computer-driven cars or a network game with one or more other humans playing against us. Sounds easy? Well, it’s not that hard, but we’ll see that a few small changes in the behavior will lead to a few other problems that have to be solved (i.e., a game menu means we have to use so-called game states). Are you ready? Great, let’s go!
Leaving the Track This gives us exactly what we need. We are able to compare the current position of any of our cars against the position in the picture. If the color is gray, everything is fine, and the car is on track. If the current position’s color is white, then the car is leaving the track, which means we will stop the car immediately. What are the black and red lines good for? The black one is the start and finish line so you can count the laps for every single player. The red one determines when the car really finished a lap. You might remember that the XNA framework updates and redraws the scenery several times a second; it wouldn’t be correct if we determined that we are on the black line several times a second and updated the lap counter more than once. The green line is there to prevent cheating. One of the first things we tried in the original game was to cross the start line, turn around, drive back, and turn around again and finally cross the start line again to get another lap counted. This is not supposed to work and is handled by the green line. Only when the green line is crossed can you pass the start line later on and get the lap counted. MICROSOFT .NET LATEST STORIES
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
|
SYS-CON FEATURED WHITEPAPERS MOST READ THIS WEEK BREAKING NEWS FROM THE WIRES
|
|||||||||||||||||||||||||||||||||||