Exemplo n.º 1
0
        public void Update(GameTime gameTime)
        {
            if (!dead)
            {
                GatherInput();
            }

            // This is unacceptable, start level over IMMEDIATELY
            if (Position.Y >= level.bottom)
            {
                scream.Play();
                level.endLevel.Invoke(0);
            }

            HandleJump();

            CheckWalls();

            if (dead)
            {
                currentClip            = death;
                animPlayer.keepPlaying = false;
            }
            else if (jumping || !grounded)
            {
                currentClip = jump;
            }
            else if (Velocity.X != 0.0f)
            {
                currentClip = walk;
            }
            else
            {
                currentClip = idle;
            }

            animPlayer.PlayContinueClip(currentClip, gameTime, 5);

            if (Velocity.X > 0)
            {
                direction = SpriteEffects.None;
            }
            else if (Velocity.X < 0)
            {
                direction = SpriteEffects.FlipHorizontally;
            }

            Position += Velocity;

            CheckCollision();

            camera.CenterOn(Position);
        }