MontyHallGame.MontyHallGame Class Reference

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

List of all members.

Public Member Functions

 MontyHallGame (bool fullscreen)
 Constructor of game.

Static Public Attributes

static MontyHallGameState state = new MontyHallGameState()
 The current game state.

Protected Member Functions

override void Initialize ()
 Allows the game to perform any initialization it needs to before starting to run. This is where it can query for any required services and load any non-graphic related content. Calling base.Initialize will enumerate through any components and initialize them as well.
override void LoadContent ()
 LoadContent will be called once per game and is the place to load all of your content.
override void UnloadContent ()
 UnloadContent will be called once per game and is the place to unload all content.
override void Update (GameTime gameTime)
 Allows the game to run logic such as updating the world, checking for collisions, gathering input, and playing audio.
override void Draw (GameTime gameTime)
 This is called when the game should draw itself.

Detailed Description

This is the main type for your game.

Definition at line 28 of file MontyHallGame.cs.


Constructor & Destructor Documentation

MontyHallGame.MontyHallGame.MontyHallGame ( bool  fullscreen  ) 

Constructor of game.

Parameters:
fullscreen Enable fullscreen mode if flag set.

Definition at line 48 of file MontyHallGame.cs.

00049         {
00050             // New input object
00051             gamepads = new Gamepads();
00052 
00053             // Content root
00054             Content.RootDirectory = "Content";
00055 
00056             // Prefer a resolution suitable for both Windows and XBox 360
00057             graphics = new GraphicsDeviceManager(this);
00058             graphics.PreferredBackBufferWidth = 853;
00059             graphics.PreferredBackBufferHeight = 480;
00060 
00061             // Maybe enable fullscreen
00062             graphics.IsFullScreen = fullscreen;
00063 
00064             // Enable antialiasing
00065             graphics.PreferMultiSampling = true;
00066 
00067             // Create the screen manager component.
00068             screenManager = new ScreenManager(this);
00069             Components.Add(screenManager);
00070         }


Member Function Documentation

override void MontyHallGame.MontyHallGame.Draw ( GameTime  gameTime  )  [protected]

This is called when the game should draw itself.

Parameters:
gameTime Provides a snapshot of timing values.

Definition at line 171 of file MontyHallGame.cs.

00172         {
00173             // Clear to black
00174             graphics.GraphicsDevice.Clear(Color.Black);
00175 
00176             // Redraw
00177             base.Draw(gameTime);
00178         }

override void MontyHallGame.MontyHallGame.Initialize (  )  [protected]

Allows the game to perform any initialization it needs to before starting to run. This is where it can query for any required services and load any non-graphic related content. Calling base.Initialize will enumerate through any components and initialize them as well.

Definition at line 78 of file MontyHallGame.cs.

00079         {
00080             // Current viewport
00081             viewport = graphics.GraphicsDevice.Viewport;
00082 
00083             // Enable mouse
00084             this.IsMouseVisible = true;
00085 
00086             // Aspect ratio
00087             float aspectRatio = graphics.GraphicsDevice.Viewport.Width /
00088                 (float)graphics.GraphicsDevice.Viewport.Height;
00089 
00090             // Create the projection matrix.
00091             projectionMatrix = Matrix.CreatePerspectiveFieldOfView(
00092                 MathHelper.ToRadians(45.0f), aspectRatio, 1f, 10000);
00093 
00094             base.Initialize();
00095         }

override void MontyHallGame.MontyHallGame.LoadContent (  )  [protected]

LoadContent will be called once per game and is the place to load all of your content.

Definition at line 101 of file MontyHallGame.cs.

00102         {
00103             // Load textures
00104             string[] doorFilenames = {
00105                                         "mdoor_ccc", "mdoor_cco", "mdoor_coc", "mdoor_coo",
00106                                         "mdoor_occ", "mdoor_oco", "mdoor_ooc", "mdoor_ooo"
00107                                     };
00108             foreach (string doorFilename in doorFilenames)
00109             {
00110                 screenManager.AddTexture(doorFilename, "Textures/" + doorFilename);
00111             }
00112 
00113             // Load sprites
00114             screenManager.AddTexture("key", "Sprites/key");
00115             screenManager.AddTexture("opensign", "Sprites/opensign");
00116             screenManager.AddTexture("monty", "Sprites/monty");
00117             screenManager.AddTexture("potogold", "Sprites/potogold");
00118 
00119             // Load fonts
00120             screenManager.AddFont("courier", "Fonts/courier");
00121             screenManager.AddFont("retro", "Fonts/retroMedium");
00122 
00123             // Create sounds
00124             screenManager.AddSound("door", "Sounds/door");
00125             screenManager.AddSound("crowd", "Sounds/gameshow_crowd");
00126             screenManager.AddSound("show", "Sounds/gameshow");
00127             screenManager.AddSound("intro", "Sounds/intro_jingle");
00128             screenManager.AddSound("loser", "Sounds/loser");
00129             screenManager.AddSound("money", "Sounds/money");
00130             screenManager.AddSound("winner", "Sounds/pick_a_winner");
00131             screenManager.AddSound("click", "Sounds/click");
00132 
00133             // Activate the first screens.
00134             screenManager.AddScreen(new MontyHallBackgroundScreen(), null);
00135             screenManager.AddScreen(new MontyHallMainMenuScreen(), null);
00136         }

override void MontyHallGame.MontyHallGame.UnloadContent (  )  [protected]

UnloadContent will be called once per game and is the place to unload all content.

Definition at line 142 of file MontyHallGame.cs.

00143         {
00144             // Unload any non ContentManager content here
00145         }

override void MontyHallGame.MontyHallGame.Update ( GameTime  gameTime  )  [protected]

Allows the game to run logic such as updating the world, checking for collisions, gathering input, and playing audio.

Parameters:
gameTime Provides a snapshot of timing values.

Definition at line 152 of file MontyHallGame.cs.

00153         {
00154             // Keyboard state
00155             KeyboardState keyState = Keyboard.GetState();
00156             Keys[] keys = keyState.GetPressedKeys();
00157 
00158             // Allows the game to exit
00159             if (keyState.IsKeyDown(Keys.Delete))
00160             {
00161                 this.Exit();
00162             }
00163 
00164             base.Update(gameTime);
00165         }


Member Data Documentation

The current game state.

Definition at line 33 of file MontyHallGame.cs.


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

Generated by  doxygen 1.6.2