]> Dogcows Code - chaz/carfire/blob - Project06/CS 3505 Project 06/CS 3505 Project 06/Game06.cs
2d8fb75b25043d3592a3a3b25ecaa7ab81e423e9
[chaz/carfire] / Project06 / CS 3505 Project 06 / CS 3505 Project 06 / Game06.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using Microsoft.Xna.Framework;
5 using Microsoft.Xna.Framework.Audio;
6 using Microsoft.Xna.Framework.Content;
7 using Microsoft.Xna.Framework.GamerServices;
8 using Microsoft.Xna.Framework.Graphics;
9 using Microsoft.Xna.Framework.Input;
10 using Microsoft.Xna.Framework.Media;
11 using Microsoft.Xna.Framework.Net;
12 using Microsoft.Xna.Framework.Storage;
13 using CS_3505_Project_06.CS_3505;
14
15 namespace CS_3505_Project_06
16 {
17 /// <summary>
18 /// A game outline for testing network communications
19 /// </summary>
20 public class Game06 : Microsoft.Xna.Framework.Game
21 {
22 GraphicsDeviceManager graphics;
23 SpriteBatch spriteBatch;
24
25 NetworkGame networkGame;
26
27 ILobby lobby;
28 IDeterministicGame deterministicGame;
29
30
31 // Constructor
32
33 public Game06()
34 {
35 graphics = new GraphicsDeviceManager(this);
36 Content.RootDirectory = "Content";
37
38 // Make the game object. The game is currently called 'testHarness'.
39
40 lobby = new lobbyGUI();
41 deterministicGame = new TestHarness();
42 networkGame = new NetworkGame(lobby, deterministicGame);
43 }
44
45 /// <summary>
46 /// Allows the game to perform any initialization it needs to before starting to run.
47 /// This is where it can query for any required services and load any non-graphic
48 /// related content. Calling base.Initialize will enumerate through any components
49 /// and initialize them as well.
50 /// </summary>
51 protected override void Initialize()
52 {
53 // Set a fixed time span of 1/60th of a second.
54
55 IsFixedTimeStep = true;
56 TargetElapsedTime = networkGame.TargetTimeSpan;
57
58 // For debugging - reset the mouse position to the center of the window.
59
60 Mouse.SetPosition(400, 300);
61
62 // Allow the base class to initialize.
63
64 base.Initialize();
65 }
66
67 /// <summary>
68 /// LoadContent will be called once per game and is the place to load
69 /// all of your content.
70 /// </summary>
71 protected override void LoadContent()
72 {
73 // Create a new SpriteBatch, which can be used to draw textures.
74
75 spriteBatch = new SpriteBatch(GraphicsDevice);
76
77 networkGame.font = Content.Load<SpriteFont>("InstructionFont");
78
79 lobby.LoadContent(Content, graphics);
80 deterministicGame.LoadContent(Content);
81 }
82
83 /// <summary>
84 /// UnloadContent will be called once per game and is the place to unload
85 /// all content.
86 /// </summary>
87 protected override void UnloadContent()
88 {
89 lobby.UnloadContent();
90 deterministicGame.UnloadContent();
91 }
92
93 /// <summary>
94 /// Allows the game to run logic such as updating the world,
95 /// checking for collisions, gathering input, and playing audio.
96 /// </summary>
97 /// <param name="gameTime">Provides a snapshot of timing values.</param>
98 protected override void Update(GameTime gameTime)
99 {
100 networkGame.Update(gameTime);
101
102 // Allow the superclass to do any needed updates (unknown purpose).
103 base.Update(gameTime);
104 }
105
106 /// <summary>
107 /// This is called when the game should draw itself.
108 /// </summary>
109 /// <param name="gameTime">Provides a snapshot of timing values.</param>
110 protected override void Draw(GameTime gameTime)
111 {
112 GraphicsDevice.Clear(new Color(16, 16, 16, 255)); // Needed by the test harness, should be removed for the real game.
113
114 spriteBatch.Begin();
115
116 // Let the game draw itself.
117 networkGame.Draw(gameTime, spriteBatch);
118
119 spriteBatch.End();
120
121 base.Draw(gameTime);
122 }
123 }
124 }
This page took 0.036635 seconds and 3 git commands to generate.