当前位置: 首页>>代码示例>>C#>>正文


C# GameTime.GetFramesPerSecond方法代码示例

本文整理汇总了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);
        }
开发者ID:ruicaridade,项目名称:IP3D,代码行数:72,代码来源:TankSim.cs


注:本文中的Microsoft.Xna.Framework.GameTime.GetFramesPerSecond方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。