- Main Page
- Classes
- Files

- File List

# C:/Users/Andreas Schiffler/Desktop/SVN/NewGamePhysics/GravityChooser/GravityChooser.cs

    00001 //-----------------------------------------------------------------------------
    00002 // GravityChooser.cs
    00003 // (A. Schiffler, 2009-2011)
    00004 //-----------------------------------------------------------------------------
    00005 namespace GravityChooser
    00006 {
    00007     using Microsoft.Xna.Framework;
    00008     using Microsoft.Xna.Framework.Graphics;
    00009     using Microsoft.Xna.Framework.Input;
    00010
    00011     using NewGamePhysics.StateManager;
    00012     using NewGamePhysics.Utilities;
    00013
    00017     public class GravityChooser : Microsoft.Xna.Framework.Game
    00018     {
    00022         public static GravityChooserState state = new GravityChooserState();
    00023
    00024         // Graphics
    00025         private GraphicsDeviceManager graphics;
    00026         private ScreenManager screenManager;
    00027         private Viewport viewport;
    00028         private Matrix projectionMatrix;
    00029
    00030         // Inputs
    00031         private Gamepads gamepads;
    00032
    00037         public GravityChooser(bool fullscreen)
    00038         {
    00039             // New input object
    00040             gamepads = new Gamepads();
    00041
    00042             // Content root
    00043             Content.RootDirectory = "Content";
    00044
    00045             // Prefer a resolution suitable for both Windows and XBox 360
    00046             graphics = new GraphicsDeviceManager(this);
    00047             graphics.PreferredBackBufferWidth = 853;
    00048             graphics.PreferredBackBufferHeight = 480;
    00049
    00050             // Maybe set to fullscreen
    00051             graphics.IsFullScreen = fullscreen;
    00052
    00053             // Enable antialiasing
    00054             graphics.PreferMultiSampling = true;
    00055
    00056             // Create the screen manager component.
    00057             screenManager = new ScreenManager(this);
    00058             Components.Add(screenManager);
    00059         }
    00060
    00067         protected override void Initialize()
    00068         {
    00069             // Current viewport
    00070             viewport = graphics.GraphicsDevice.Viewport;
    00071
    00072             // Enable mouse
    00073             this.IsMouseVisible = true;
    00074
    00075             // Aspect ratio
    00076             float aspectRatio = graphics.GraphicsDevice.Viewport.Width /
    00077                 (float)graphics.GraphicsDevice.Viewport.Height;
    00078
    00079             // Create the projection matrix.
    00080             projectionMatrix = Matrix.CreatePerspectiveFieldOfView(
    00081                 MathHelper.ToRadians(45.0f), aspectRatio, 1f, 10000);
    00082
    00083             base.Initialize();
    00084         }
    00085
    00090         protected override void LoadContent()
    00091         {
    00092             // Load textures
    00093
    00094             // Load fonts
    00095             screenManager.AddFont("retro", "Fonts/retroMedium");
    00096             screenManager.AddFont("courier", "Fonts/courier");
    00097
    00098             // Activate the first screens.
    00099             screenManager.AddScreen(new GravityChooserBackgroundScreen(), null);
    00100             screenManager.AddScreen(new GravityChooserMainMenuScreen(), null);
    00101         }
    00102
    00107         protected override void UnloadContent()
    00108         {
    00109             // Unload any non ContentManager content here
    00110         }
    00111
    00117         protected override void Update(GameTime gameTime)
    00118         {
    00119             // Keyboard state
    00120             KeyboardState keyState = Keyboard.GetState();
    00121             Keys[] keys = keyState.GetPressedKeys();
    00122
    00123             // Allows the game to exit
    00124             if (keyState.IsKeyDown(Keys.Delete))
    00125             {
    00126                 this.Exit();
    00127             }
    00128
    00129             // Check gamepad
    00130             if ((gamepads != null) && (gamepads.Items.Count > 0))
    00131             {
    00132             }
    00133
    00134             base.Update(gameTime);
    00135         }
    00136
    00141         protected override void Draw(GameTime gameTime)
    00142         {
    00143             // Clear to black
    00144             graphics.GraphicsDevice.Clear(Color.Black);
    00145
    00146             // Redraw
    00147             base.Draw(gameTime);
    00148         }
    00149     }
    00150 }