本文整理汇总了C#中Microsoft.Xna.Framework.GameTime.GetFramesPerSecond方法的典型用法代码示例。如果您正苦于以下问题:C# GameTime.GetFramesPerSecond方法的具体用法?C# GameTime.GetFramesPerSecond怎么用?C# GameTime.GetFramesPerSecond使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.GameTime
的用法示例。
在下文中一共展示了GameTime.GetFramesPerSecond方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Update
/// <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)
{
IsActive = base.IsActive;
if (!IsActive) return;
if (Input.IsKeyPressed(Keys.F1))
{
Debugging = !Debugging;
DebugHud.DebugStringPanels[0].Get("toggle_debug").Text = "Debug Mode (F1): " + Debugging;
}
if (Input.IsKeyPressed(Keys.P))
{
spectating = !spectating;
DebugHud.DebugStringPanels[0].Get("spectate_info").Text = "Spectator Camera (P): " + spectating;
}
OnGameUpdate(gameTime);
MainCamera.Update(gameTime);
tank.Update(gameTime, map);
MainCamera.Position = new Vector3(tank.Position.X - tank.Front.X * 8.0f, tank.Position.Y + 8.0f,
tank.Position.Z - tank.Front.Z * 8.0f);
SpectatorCamera.Update(gameTime);
aiTank.Update(gameTime, map);
SpectatorCamera.Position = new Vector3(aiTank.Position.X - aiTank.Front.X * 8.0f, aiTank.Position.Y + 8.0f,
aiTank.Position.Z - aiTank.Front.Z * 8.0f);
float camAngle = tank.Yaw + 90.0f;
if (camAngle > 360.0f)
{
camAngle = camAngle - 360.0f;
}
MainCamera.Yaw = camAngle;
camAngle = aiTank.Yaw + 90.0f;
if (camAngle > 360.0f)
{
camAngle = camAngle - 360.0f;
}
SpectatorCamera.Yaw = camAngle;
rainEmitter.Update(gameTime);
dustEmitter.Start = tank.Position - tank.Right * 2 - tank.Front * 3.5f;
dustEmitter.End = tank.Position + tank.Right * 2 - tank.Front * 3.5f;
dustEmitter.Velocity = new Vector3(10.0f * -tank.Front.X,
25.0f, 10.0f * -tank.Front.Z);
dustEmitter.Interval = tank.IsMoving ? 0.01f : float.MaxValue;
dustEmitter.Update(gameTime);
effect.Projection = MainCamera.Projection;
effect.View = MainCamera.View;
DebugHud.DebugStringPanels[0].Get("fps").Text = "FPS: " + gameTime.GetFramesPerSecond();
DebugHud.DebugStringPanels[0].Get("delta_time").Text = "Delta Time: " + gameTime.GetDeltaTime();
if (Input.IsKeyPressed(Keys.Escape))
{
Exit();
}
base.Update(gameTime);
}