예제 #1
0
파일: Game1.cs 프로젝트: mildmelon/mini2Dx
        /// <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)
        {
            float delta = (float)gameTime.ElapsedGameTime.TotalSeconds;

            if (delta > _updateMaximumDelta)
            {
                delta = _updateMaximumDelta;
            }

            _timeAccumulator += delta;

            while (_timeAccumulator >= targetTimeStep)
            {
                ((MonoGameInput)Mdx.input).update();
                ((MonoGameAudio)Mdx.audio).update();
                game.update(targetTimeStep);
                _timeAccumulator -= targetTimeStep;
            }
            game.interpolate(_timeAccumulator / targetTimeStep);

            base.Update(gameTime);
        }