Ejemplo n.º 1
0
        /// <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)
        {
            if (Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }
            //TODO trouver une alternative au IsKeyDown type IsKeyPressed
            if (Keyboard.GetState().IsKeyDown(Keys.P))
            {
                isDown = true;
            }
            if (isDown && !Keyboard.GetState().IsKeyDown(Keys.P))
            {
                isDown = false;
                paused = !paused;
            }

            // Reset l'état de la simulation
            if (Keyboard.GetState().IsKeyDown(Keys.R))
            {
                separatedInitialization();
                LoadContent();
            }
            if (!paused)
            {
                world.updateWorld(gameTime.ElapsedGameTime.Milliseconds);
                //I moved that one up here hopping it will stop the gameTime incrementation when paused
                //Console.Out.WriteLine("FPS : " + (1.0f/gameTime.ElapsedGameTime.Milliseconds)*1000);
                base.Update(gameTime);
            }
        }