コード例 #1
0
        // Call with StandardTetrisTimeT::GetIntervalDurationSecondsFloat() in main()

        public static void PerformGameIterations
        (
            STGame game,
            double deltaTimeSeconds
        )
        {
            // First, update the game time.
            game.ConditionalAdvanceGameTimeByDelta(deltaTimeSeconds);


            int gameSpeed = 0;

            gameSpeed = game.GetGameSpeedAdjustment( );

            if (gameSpeed <= 2)
            {
                // Perform any unforced game iteration.
                game.ConditionalAdvanceGameIteration(false);
            }
            else
            {
                int totalIncrements  = (8 * gameSpeed);
                int incrementCounter = 0;
                for
                (
                    incrementCounter = 0;
                    incrementCounter < totalIncrements;
                    incrementCounter++
                )
                {
                    game.ConditionalAdvanceGameIteration(true);
                }
            }



            // Update reported frame rate
            {
                float frameDurationSeconds = 0.0f;
                frameDurationSeconds = (float)deltaTimeSeconds;

                float framesPerSecond = 0.0f;
                if (frameDurationSeconds > 0.0001f)
                {
                    framesPerSecond = (1.0f / frameDurationSeconds);
                }
                if (framesPerSecond < 0.0f)
                {
                    framesPerSecond = 0.0f;
                }
                game.SetReportedFrameRate(framesPerSecond);
            }
        }