00001
00002
00003
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
00025 private GraphicsDeviceManager graphics;
00026 private ScreenManager screenManager;
00027 private Viewport viewport;
00028 private Matrix projectionMatrix;
00029
00030
00031 private Gamepads gamepads;
00032
00037 public GravityChooser(bool fullscreen)
00038 {
00039
00040 gamepads = new Gamepads();
00041
00042
00043 Content.RootDirectory = "Content";
00044
00045
00046 graphics = new GraphicsDeviceManager(this);
00047 graphics.PreferredBackBufferWidth = 853;
00048 graphics.PreferredBackBufferHeight = 480;
00049
00050
00051 graphics.IsFullScreen = fullscreen;
00052
00053
00054 graphics.PreferMultiSampling = true;
00055
00056
00057 screenManager = new ScreenManager(this);
00058 Components.Add(screenManager);
00059 }
00060
00067 protected override void Initialize()
00068 {
00069
00070 viewport = graphics.GraphicsDevice.Viewport;
00071
00072
00073 this.IsMouseVisible = true;
00074
00075
00076 float aspectRatio = graphics.GraphicsDevice.Viewport.Width /
00077 (float)graphics.GraphicsDevice.Viewport.Height;
00078
00079
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
00093
00094
00095 screenManager.AddFont("retro", "Fonts/retroMedium");
00096 screenManager.AddFont("courier", "Fonts/courier");
00097
00098
00099 screenManager.AddScreen(new GravityChooserBackgroundScreen(), null);
00100 screenManager.AddScreen(new GravityChooserMainMenuScreen(), null);
00101 }
00102
00107 protected override void UnloadContent()
00108 {
00109
00110 }
00111
00117 protected override void Update(GameTime gameTime)
00118 {
00119
00120 KeyboardState keyState = Keyboard.GetState();
00121 Keys[] keys = keyState.GetPressedKeys();
00122
00123
00124 if (keyState.IsKeyDown(Keys.Delete))
00125 {
00126 this.Exit();
00127 }
00128
00129
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
00144 graphics.GraphicsDevice.Clear(Color.Black);
00145
00146
00147 base.Draw(gameTime);
00148 }
00149 }
00150 }