protected override void Update(GameTime gameTime) { timeRuler.StartFrame(); updateMarker.Begin(); KeyboardState keyState = Keyboard.GetState(); if (keyState.IsKeyDown(Keys.Escape)) { Exit(); } float dt = (float)gameTime.ElapsedGameTime.TotalSeconds; // スペースキーで次の描画手法に変更する if (keyState.IsKeyDown(Keys.Space)) { if (!pressedSpaceKey) { MoveToNextTechnique(); } pressedSpaceKey = true; } else { pressedSpaceKey = false; } // ゲームオブジェクト数を増やす float trigger = keyState.IsKeyDown(Keys.Up) ? 0.1f : 0.0f; if (trigger > 0.0f) { int addCount = Math.Max(1, (int)(trigger * 2000.0f * dt)); targetObjectCount = Math.Min(targetObjectCount + addCount, MaxGameObjectCount); UpdateStatusString(); } // ゲームオブジェクト数を減らす trigger = keyState.IsKeyDown(Keys.Down) ? 0.1f : 0.0f; if (trigger > 0.0f) { int subCount = Math.Max(1, (int)(trigger * 2000.0f * dt)); targetObjectCount = Math.Max(targetObjectCount - subCount, 1); UpdateStatusString(); } // 全ゲームオブジェクトの更新 UpdateGameObjects(dt); updateMarker.End(); base.Update(gameTime); }
protected override void Update(GameTime gameTime) { timeRuler.StartFrame(); updateMarker.Begin(); base.Update(gameTime); updateMarker.End(); }
protected override void Draw(GameTime gameTime) { drawMarker.Begin(); GraphicsDevice.Clear(Color.CornflowerBlue); base.Draw(gameTime); drawMarker.End(); }
protected override void Update(GameTime gameTime) { timeRuler.StartFrame(); updateMarker.Begin(); if (storageManager.RootDirectory == null) { storageManager.Select("BlockViewer"); } base.Update(gameTime); updateMarker.End(); }
protected override void Draw(GameTime gameTime) { drawMarker.Begin(); GraphicsDevice.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.CornflowerBlue, 1, 0); // ゲームオブジェクトの描画 DrawGameObjects(); // ステータス表示 float margin = font.LineSpacing * 0.2f; Vector2 size = font.MeasureString(statusString); size.Y += margin * 2.0f; var layout = new DebugLayout(); layout.ContainerBounds = GraphicsDevice.Viewport.Bounds; layout.Width = (int)size.X; layout.Height = (int)size.Y; layout.HorizontalAlignment = DebugHorizontalAlignment.Left; layout.VerticalAlignment = DebugVerticalAlignment.Top; layout.HorizontalMargin = 8; layout.VerticalMargin = 8; layout.Arrange(); spriteBatch.Begin(); spriteBatch.Draw(fillTexture, layout.ArrangedBounds, new Color(0, 0, 0, 200)); spriteBatch.DrawString( font, statusString, new Vector2(layout.ArrangedBounds.X, layout.ArrangedBounds.Y + margin), Color.White); spriteBatch.End(); drawMarker.End(); base.Draw(gameTime); }