--- /dev/null
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using Microsoft.Xna.Framework;\r
+using Microsoft.Xna.Framework.Audio;\r
+using Microsoft.Xna.Framework.Content;\r
+using Microsoft.Xna.Framework.GamerServices;\r
+using Microsoft.Xna.Framework.Graphics;\r
+using Microsoft.Xna.Framework.Input;\r
+using Microsoft.Xna.Framework.Media;\r
+using Microsoft.Xna.Framework.Net;\r
+using Microsoft.Xna.Framework.Storage;\r
+\r
+namespace CarFire\r
+{\r
+ /// <summary>\r
+ /// This is the main type for your game\r
+ /// </summary>\r
+ public class XnaGame : Microsoft.Xna.Framework.Game\r
+ {\r
+ GraphicsDeviceManager graphics;\r
+ SpriteBatch spriteBatch;\r
+\r
+ NetworkManager networkGame;\r
+ IScreenManager screenManager;\r
+ IDeterministicGame deterministicGame;\r
+\r
+ public XnaGame()\r
+ {\r
+ graphics = new GraphicsDeviceManager(this);\r
+ Content.RootDirectory = "Content";\r
+\r
+ Components.Add(new GamerServicesComponent(this));\r
+\r
+ screenManager = new ScreenManager();\r
+ deterministicGame = new Game();\r
+ networkGame = new NetworkManager(screenManager, deterministicGame);\r
+\r
+ Vector2 size = deterministicGame.PreferredScreenSize;\r
+ graphics.PreferredBackBufferWidth = (int)size.X;\r
+ graphics.PreferredBackBufferHeight = (int)size.Y;\r
+ graphics.ApplyChanges();\r
+ }\r
+\r
+ /// <summary>\r
+ /// Allows the game to perform any initialization it needs to before starting to run.\r
+ /// This is where it can query for any required services and load any non-graphic\r
+ /// related content. Calling base.Initialize will enumerate through any components\r
+ /// and initialize them as well.\r
+ /// </summary>\r
+ protected override void Initialize()\r
+ {\r
+ IsFixedTimeStep = true;\r
+ TargetElapsedTime = networkGame.TargetTimeSpan;\r
+\r
+ base.Initialize();\r
+ }\r
+\r
+ /// <summary>\r
+ /// LoadContent will be called once per game and is the place to load\r
+ /// all of your content.\r
+ /// </summary>\r
+ protected override void LoadContent()\r
+ {\r
+ // Create a new SpriteBatch, which can be used to draw textures.\r
+ spriteBatch = new SpriteBatch(GraphicsDevice);\r
+\r
+ screenManager.LoadContent(Content, graphics);\r
+ deterministicGame.LoadContent(Content);\r
+ }\r
+\r
+ /// <summary>\r
+ /// UnloadContent will be called once per game and is the place to unload\r
+ /// all content.\r
+ /// </summary>\r
+ protected override void UnloadContent()\r
+ {\r
+ screenManager.UnloadContent();\r
+ deterministicGame.UnloadContent();\r
+ }\r
+\r
+ /// <summary>\r
+ /// Allows the game to run logic such as updating the world,\r
+ /// checking for collisions, gathering input, and playing audio.\r
+ /// </summary>\r
+ /// <param name="gameTime">Provides a snapshot of timing values.</param>\r
+ protected override void Update(GameTime gameTime)\r
+ {\r
+ networkGame.Update(gameTime);\r
+\r
+ base.Update(gameTime);\r
+ }\r
+\r
+ /// <summary>\r
+ /// This is called when the game should draw itself.\r
+ /// </summary>\r
+ /// <param name="gameTime">Provides a snapshot of timing values.</param>\r
+ protected override void Draw(GameTime gameTime)\r
+ {\r
+ GraphicsDevice.Clear(Color.Red);\r
+\r
+ spriteBatch.Begin();\r
+ networkGame.Draw(gameTime, spriteBatch);\r
+ spriteBatch.End();\r
+\r
+ base.Draw(gameTime);\r
+ }\r
+ }\r
+}\r