/// <summary>\r
/// This is the main type for your game\r
/// </summary>\r
- public class Game1 : Microsoft.Xna.Framework.Game\r
+ public class XnaGame : Microsoft.Xna.Framework.Game\r
{\r
GraphicsDeviceManager graphics;\r
SpriteBatch spriteBatch;\r
\r
- public Game1()\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
/// </summary>\r
protected override void Initialize()\r
{\r
- // TODO: Add your initialization logic here\r
+ IsFixedTimeStep = true;\r
+ TargetElapsedTime = networkGame.TargetTimeSpan;\r
\r
base.Initialize();\r
}\r
// Create a new SpriteBatch, which can be used to draw textures.\r
spriteBatch = new SpriteBatch(GraphicsDevice);\r
\r
- // TODO: use this.Content to load your game content here\r
+ screenManager.LoadContent(Content, graphics);\r
+ deterministicGame.LoadContent(Content);\r
}\r
\r
/// <summary>\r
/// </summary>\r
protected override void UnloadContent()\r
{\r
- // TODO: Unload any non ContentManager content here\r
+ screenManager.UnloadContent();\r
+ deterministicGame.UnloadContent();\r
}\r
\r
/// <summary>\r
/// <param name="gameTime">Provides a snapshot of timing values.</param>\r
protected override void Update(GameTime gameTime)\r
{\r
- // Allows the game to exit\r
- if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)\r
- this.Exit();\r
-\r
- // TODO: Add your update logic here\r
+ networkGame.Update(gameTime);\r
\r
base.Update(gameTime);\r
}\r
/// <param name="gameTime">Provides a snapshot of timing values.</param>\r
protected override void Draw(GameTime gameTime)\r
{\r
- GraphicsDevice.Clear(Color.CornflowerBlue);\r
+ GraphicsDevice.Clear(Color.Red);\r
\r
- // TODO: Add your drawing code here\r
+ spriteBatch.Begin();\r
+ networkGame.Draw(gameTime, spriteBatch);\r
+ spriteBatch.End();\r
\r
base.Draw(gameTime);\r
}\r