예제 #1
0
파일: Pacman.cs 프로젝트: vitpunch/pacman
        private void GoCell()
        {
            if (x == 1 && direction == Direction.left)
            {
                Labirint.PrintArroundDot(x, y);
                x = 28;
            }

            if (x == 26 && direction == Direction.right)
            {
                Labirint.PrintArroundDot(x, y);
                x = 1;
            }
            switch (direction)
            {
            case Direction.right:
                x++;
                break;

            case Direction.left:
                x--;
                break;

            case Direction.up:
                y--;
                break;

            case Direction.down:
                y++;
                break;

            case Direction.stop:
                break;
            }
            if (Labirint.MayPassToDot(x, y, newDirection))
            {
                direction = newDirection;
            }
            else
            if (!Labirint.MayPassToDot(x, y, direction))
            {
                direction = Direction.stop;
            }
            if (Labirint.GetDot(x, y) == '.')
            {
                Labirint.SetEmpty(x, y);
                eatedDots++;
            }
        }
예제 #2
0
파일: Pacman.cs 프로젝트: vitpunch/pacman
 public void Go()
 {
     pixelShift = timeCalculator.PixelShift(speed);
     mouth     += mouthDirection;
     if (mouth > 45 || mouth < 0)
     {
         mouthDirection = -mouthDirection;
     }
     shift += pixelShift;
     if (shift > 19)
     {
         shift -= 20;
         GoCell();
     }
     Labirint.PrintArroundDot(x, y);
     Draw();
     MainForm.picture.Refresh();
 }