/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { const string mark = "Update"; try { base.Update(gameTime); //We must call StartFrame at the top of Update to indicate to the Profiler that a new frame has started. GS.StartFrame(); GS.BeginMark(mark, FlatTheme.PeterRiver); _previousKeyboardState = _keyboardState; _keyboardState = Keyboard.GetState(); // Allows the game to exit #if WINDOWS if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { Exit(); return; } #endif if (_keyboardState.IsKeyUp(Keys.Escape) && _previousKeyboardState.IsKeyDown(Keys.Escape)) { Exit(); return; } #if USE_GEARSET //Test for CPU / GPU bound if (GS.GearsetComponent.Console.Profiler.DoUpdate() == false) { return; } #endif //PLOT test GS.Plot("FPS", _fpsCounter.Fps); // GS.Plot("Tick Memory K", _memoryMonitor.TickMemoryK); var mouseState = Mouse.GetState(); var mousePos2 = new Vector2(mouseState.X, mouseState.Y); var mousePos3 = new Vector3(mousePos2, 0); //Label test GS.ShowLabel("I follow the mouse pointer!", mousePos2); //Line Test //Draw a line but then use the same key to reference it a second time and alter the postion / color // GS.ShowLine("TestLine", new Vector2(mouseState.X, mouseState.Y + 20), new Vector2(mouseState.X + 200, mouseState.Y + 20), Color.Green); // GS.ShowLine("TestLine", new Vector2(mouseState.X, mouseState.Y - 20), new Vector2(mouseState.X + 200, mouseState.Y - 20), Color.Violet); //Other lines... GS.ShowLineOnce(new Vector2(mouseState.X, mouseState.Y + 25), new Vector2(mouseState.X + 200, mouseState.Y + 25), Color.Pink); GS.ShowLineOnce(new Vector2(mouseState.X, mouseState.Y + 35), new Vector2(mouseState.X + 200, mouseState.Y + 35), Color.Red); //ALERT test - press SPACE for an alert message! if (_keyboardState.IsKeyUp(Keys.Space) && _previousKeyboardState.IsKeyDown(Keys.Space)) { GS.Alert("I am an alert message"); } Thread.Sleep(1);//Let's trick the update into taking some time so that we can see some profile info //Update Gearset matrixes for 3d geometry GS.SetMatrices(ref _worldMatrix, ref _viewMatrix, ref _projectionMatrix); //Geometry tests... // GS.ShowSphere("TestSphere", mousePos3, 50, Color.Azure); GS.ShowSphereOnce(mousePos3, 50, Color.Azure); // GS.ShowBox("TestBox", new Vector3(mouseState.X + 50, mouseState.Y + 50, 0), new Vector3(mouseState.X + 100, mouseState.Y + 100, 0), Color.Blue); GS.ShowBoxOnce(new Vector3(mouseState.X + 100, mouseState.Y + 100, 0), new Vector3(mouseState.X + 150, mouseState.Y + 150, 0), Color.Red); } finally { //Must call EndMark GS.EndMark(mark); } }