Exemplo n.º 1
0
        /// <summary>
        /// Méthode de mise à jour du jeu suite aux actions
        /// </summary>
        /// <param name="gameTime"></param>
        protected override void Update(GameTime gameTime)
        {
            //Check sortie du jeu
            if (Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            //Check redimensionnement de la fenêtre graphique
            if (backbufferHeight != GraphicsDevice.PresentationParameters.BackBufferHeight ||
                backbufferWidth != GraphicsDevice.PresentationParameters.BackBufferWidth)
            {
                ScalePresentationArea();
            }

            keyboardState = Keyboard.GetState();

            if (onLevel)
            {
                System.Diagnostics.Debug.WriteLine("\n\nNOUS SOMMES DANS LE LEVEL");
                level.Update(gameTime, keyboardState);
                LevelPlayer.Update(gameTime, keyboardState);
                LevelPlayer.Position = LevelPlayer.NextPosition;
                System.Diagnostics.Debug.WriteLine("[level] POSITION APRES UPDATE " + LevelPlayer.PositionLevel.X + "  :  " + LevelPlayer.PositionLevel.Y);
            }
            else
            {
                Player.Update(gameTime, keyboardState);

                if (CanMove((int)Player.NextPosition.X, (int)Player.NextPosition.Y))
                {
                    Player.Position = Player.NextPosition;
                    System.Diagnostics.Debug.WriteLine("POSITION APRES UPDATE " + Player.Position.X + "  :  " + Player.Position.Y + "\n\n");
                }
            }

            //base.Update(gameTime);
        }