# PendulumGame.PendulumGame Class Reference

This is the main type for your game. More...

List of all members.

## Public Member Functions
| PendulumGame ()
| Constructor of pendulum game.
## Public Attributes
const string | PlayTrulyRandomAgentName = "PendulumGame_v3"
| The agent name for PlayTrulyRandom.
## Protected Member Functions
override void | Initialize ()
| Initialize: load base initialize/.
override void | LoadContent ()
| LoadContent: load some common content used across all of pendulum game.
override void | UnloadContent ()
| Unload all pendulum game content.
override void | Update (GameTime gameTime)
| Default updater: calls base update.
override void | Draw (GameTime gameTime)
| Default draw: black screen.
## Properties
static PendulumGameState | State`[get]`
| Gets the current game state for PendulumGame.

## Detailed Description

This is the main type for your game.

Definition at line 20 of file PendulumGame.cs.

## Constructor & Destructor Documentation

PendulumGame.PendulumGame.PendulumGame | ( |  | ) |

Constructor of pendulum game.

Definition at line 55 of file PendulumGame.cs.

    00056         {
    00057             // Parse command-line parameters
    00058             bool fullscreen = false;
    00059             bool oneGamepad = false;
    00060             bool disableShaders = false;
    00061             bool xboxResolution = false;
    00062             bool audioOnDemand = false;
    00063             string[] args = System.Environment.GetCommandLineArgs();
    00064             if (args.Length > 1)
    00065             {
    00066                 for (int i = 1; i < args.Length; i++)
    00067                 {
    00068                     if (!string.IsNullOrEmpty(args[i]))
    00069                     {
    00070                         if (args[i].Equals("/fullscreen", StringComparison.InvariantCultureIgnoreCase))
    00071                         {
    00072                             fullscreen = true;
    00073                         }
    00074                         else if (args[i].Equals("/onegamepad", StringComparison.InvariantCultureIgnoreCase))
    00075                         {
    00076                             oneGamepad = true;
    00077                         }
    00078                         else if (args[i].Equals("/twogamepads", StringComparison.InvariantCultureIgnoreCase))
    00079                         {
    00080                             oneGamepad = false;
    00081                         }
    00082                         else if (args[i].Equals("/noshaders", StringComparison.InvariantCultureIgnoreCase))
    00083                         {
    00084                             disableShaders = true;
    00085                         }
    00086                         else if (args[i].Equals("/xboxscreen", StringComparison.InvariantCultureIgnoreCase))
    00087                         {
    00088                             xboxResolution = true;
    00089                         }
    00090                         else if (args[i].Equals("/audioondemand", StringComparison.InvariantCultureIgnoreCase))
    00091                         {
    00092                             audioOnDemand = true;
    00093                         }
    00094                         else
    00095                         {
    00096                             System.Console.WriteLine("PendulumGame [/fullscreen] [/xboxscreen] [/noshaders] [/onegamepad|/twogamepads] [/audioondemand]");
    00097                         }
    00098                     }
    00099                 }
    00100             }
    00101
    00102             // Create game state
    00103             state = new PendulumGameState();
    00104
    00105             // Set content root
    00106             Content.RootDirectory = "Content";
    00107
    00108             // Setup graphics
    00109             GraphicsDeviceManager graphics = new GraphicsDeviceManager(this);
    00110
    00111             // Designed for a resolution suitable for both Windows and XBox 360
    00112             if (xboxResolution)
    00113             {
    00114                 // Xbox
    00115                 graphics.PreferredBackBufferWidth = 853;
    00116                 graphics.PreferredBackBufferHeight = 480;
    00117                 PendulumGame.State.Scale = new Vector2(1.0f, 1.0f);
    00118             }
    00119             else
    00120             {
    00121                 // XGA
    00122                 graphics.PreferredBackBufferWidth = 1024;
    00123                 graphics.PreferredBackBufferHeight = 768;
    00124                 PendulumGame.State.Scale = new Vector2(
    00125                     (float)1024 / (float)853,
    00126                     (float)768 / (float)480);
    00127             }
    00128
    00129             // Maybe enable fullscreen mode
    00130             graphics.IsFullScreen = fullscreen;
    00131
    00132             // Enable antialiasing
    00133             graphics.PreferMultiSampling = true;
    00134
    00135             // Enable on-demand real-time audio
    00136             PendulumGame.State.RealtimeAudioOnDemand = audioOnDemand;
    00137
    00138             // Store gamepad choice
    00139             PendulumGame.State.UseOnlyOneGamepad = oneGamepad;
    00140
    00141             // Store shader choice
    00142             PendulumGame.State.DisablePixelShaderEffects = disableShaders;
    00143
    00144             // Enable mouse
    00145             this.IsMouseVisible = true;
    00146
    00147             // Create the screen manager component.
    00148             screenManager = new ScreenManager(this);
    00149             Components.Add(screenManager);
    00150         }

## Member Function Documentation

override void PendulumGame.PendulumGame.Draw | ( | GameTime | gameTime | ) | `[protected]`

Default draw: black screen.

Parameters:

  | gameTime | Provides a snapshot of timing values.

Definition at line 244 of file PendulumGame.cs.

    00245         {
    00246             // Clear to black
    00247             this.GraphicsDevice.Clear(Color.Black);
    00248
    00249             // Redraw
    00250             base.Draw(gameTime);
    00251         }

override void PendulumGame.PendulumGame.Initialize | ( |  | ) | `[protected]`

Initialize: load base initialize/.

Definition at line 163 of file PendulumGame.cs.

    00164         {
    00165             base.Initialize();
    00166         }

override void PendulumGame.PendulumGame.LoadContent | ( |  | ) | `[protected]`

LoadContent: load some common content used across all of pendulum game.

Definition at line 171 of file PendulumGame.cs.

    00172         {
    00173             // Load textures
    00174             screenManager.Textures.Add("rivet", Content.Load<Texture2D>("Sprites/rivet"));
    00175             screenManager.Textures.Add("metal", Content.Load<Texture2D>("Sprites/metal_texture"));
    00176             //
    00177             screenManager.Textures.Add("apple", Content.Load<Texture2D>("Sprites/red_apple"));
    00178             screenManager.Textures.Add("copperball", Content.Load<Texture2D>("Sprites/copperball"));
    00179             screenManager.Textures.Add("silverball", Content.Load<Texture2D>("Sprites/silverball"));
    00180             screenManager.Textures.Add("goldball", Content.Load<Texture2D>("Sprites/goldball"));
    00181             screenManager.Textures.Add("duck", Content.Load<Texture2D>("Sprites/yellow_duck"));
    00182
    00183             // Load fonts
    00184             screenManager.Fonts.Add("retro", Content.Load<SpriteFont>("Fonts/retroMedium"));
    00185             screenManager.Fonts.Add("courier", Content.Load<SpriteFont>("Fonts/courier"));
    00186
    00187             // Load info links
    00188             string fileContent;
    00189             this.infoLinkCollections = new Dictionary<string, InfoLink[]>();
    00190             string[] infoLinkTopics = { "Gravity", "DoublePendulum", "Randomness" };
    00191             foreach (string topic in infoLinkTopics)
    00192             {
    00193                 fileContent =
    00194                     System.IO.File.ReadAllText(@"InfoLinkData\" + topic + ".xml", Encoding.Unicode);
    00195                 if (!string.IsNullOrEmpty(fileContent))
    00196                 {
    00197                     InfoLink[] infoLinks =
    00198                         InfoLinkSerializer.DeserializeArray(fileContent);
    00199                     if (infoLinks != null)
    00200                     {
    00201                         this.infoLinkCollections.Add(topic, infoLinks);
    00202                     }
    00203                 }
    00204             }
    00205
    00206             // Open webservice link
    00207             this.playTrulyRandomWebservice = new PlayTrulyRandom(
    00208                     PlayTrulyRandomAgentName);
    00209             this.playTrulyRandomWebservice.RegisterAgent();
    00210
    00211             // Transmitter for info links
    00212             infoLinkTransmitter = new InfoLinkTransmitter();
    00213             infoLinkTransmitter.StartTransmitter();
    00214
    00215             // Activate the first screens.
    00216             screenManager.AddScreen(new PendulumBackgroundScreen(), null);
    00217             screenManager.AddScreen(new PendulumMainMenuScreen(), null);
    00218         }

override void PendulumGame.PendulumGame.UnloadContent | ( |  | ) | `[protected]`

Unload all pendulum game content.

Definition at line 223 of file PendulumGame.cs.

    00224         {
    00225             // Shut down transmitter
    00226             infoLinkTransmitter.StopTransmitter();
    00227
    00228             base.UnloadContent();
    00229         }

override void PendulumGame.PendulumGame.Update | ( | GameTime | gameTime | ) | `[protected]`

Default updater: calls base update.

Parameters:

  | gameTime | Provides a snapshot of timing values.

Definition at line 235 of file PendulumGame.cs.

    00236         {
    00237             base.Update(gameTime);
    00238         }

## Member Data Documentation

const string PendulumGame.PendulumGame.PlayTrulyRandomAgentName = "PendulumGame_v3"

The agent name for PlayTrulyRandom.

Definition at line 25 of file PendulumGame.cs.

## Property Documentation

PendulumGameState PendulumGame.PendulumGame.State`[static, get]`

Gets the current game state for PendulumGame.

Definition at line 156 of file PendulumGame.cs.

The documentation for this class was generated from the following file:

- C:/Users/Andreas Schiffler/Desktop/SVN/NewGamePhysics/PendulumGame/PendulumGame.cs