예제 #1
0
 public void MoveRight(PlayerAnimations animation, Level level, GameTime gameTime, Collision collision)
 {
     if (!collision.checkPlayerLevelCollision(animation, this, level).Contains("Right"))
     {
         animation.BotState = PlayerAnimations.BottomAnimationState.Walking;
         if (!screenLocked)
         {
             level.MoveLevel(1);
         }
         else
         {
             if (location.X < GlobalVars.resolutionWidth - animation.playerTex[animation.currentframe].Width)
             {
                 location += new Vector2(GlobalVars.playerSpeed, 0);
             }
         }
     }
 }
예제 #2
0
        public void UpdateHeight(PlayerAnimations animation, Level level, Collision collision)
        {
            if (jumping && allowJump)
            {
                if (grounded)
                {
                    velocity = 15f;
                }

                grounded = false;
                location = new Vector2(location.X, location.Y - velocity);
                velocity -= 0.5f;
                if (velocity <= 0)
                {
                    jumping = false;
                    allowJump = false;
                }
            }
            else
            {
                if (grounded)
                {
                    velocity = 1f;
                }
                if (!collision.checkPlayerLevelCollision(animation, this, level).Contains("Bottom"))
                {
                    if (velocity <= 15)
                    {
                        velocity += 0.5f;
                    }
                    location = new Vector2(location.X, location.Y + velocity);
                    allowJump = false;
                    grounded = false;
                }
                else
                {
                    grounded = true;
                    allowJump = true;
                }
            }
        }
예제 #3
0
        public void MoveLeft(PlayerAnimations animation, Level level, GameTime gameTime, Collision collision)
        {
            if (level.location > 0)
            {
                if (!collision.checkPlayerLevelCollision(animation, this, level).Contains("Left"))
                {
                    animation.Moving(gameTime);

                    if (!screenLocked)
                    {
                        level.MoveLevel(-1);
                    }
                    else
                    {
                        if (location.X > 0)
                        {
                            location -= new Vector2(GlobalVars.playerSpeed, 0);
                        }
                    }
                }
            }
        }