コード例 #1
0
 public void Move(int palyaW, int palyaH, Direction irany)
 {
     elozoIrany = irany;
     if (irany == Direction.Up && playerShape.Area.Top - speed >= 0)
     {
         playerShape.ChangeY(-speed);
     }
     else if (irany == Direction.Down && playerShape.Area.Bottom + speed <= palyaH)
     {
         playerShape.ChangeY(speed);
     }
     else if (irany == Direction.Left && playerShape.Area.Left - speed >= 0)
     {
         playerShape.ChangeX(-speed);
     }
     else if (irany == Direction.Right && playerShape.Area.Right + speed <= palyaW)
     {
         playerShape.ChangeX(speed);
     }
     else if (irany == Direction.UpRight && playerShape.Area.Right + speed <= palyaW && playerShape.Area.Top <= palyaH)
     {
         playerShape.ChangeX(speed);
         playerShape.ChangeY(-speed);
     }
     else if (irany == Direction.UpLeft && playerShape.Area.Left - speed >= 0 && playerShape.Area.Top <= palyaH)
     {
         playerShape.ChangeX(-speed);
         playerShape.ChangeY(-speed);
     }
     else if (irany == Direction.DownLeft && playerShape.Area.Left - speed >= 0 && playerShape.Area.Bottom >= 0)
     {
         playerShape.ChangeX(-speed);
         playerShape.ChangeY(speed);
     }
     else if (irany == Direction.DownRight && playerShape.Area.Right + speed <= palyaW && playerShape.Area.Bottom >= 0)
     {
         playerShape.ChangeX(speed);
         playerShape.ChangeY(speed);
     }
 }