Exemplo n.º 1
0
        private void Pacmantimer_Tick(object sender, EventArgs e)
        {
            switch (direction)
            {
            case 1:
                pack.Move(Characters.MovementWay.Up);
                break;

            case 2:
                pack.Move(Characters.MovementWay.Down);
                break;

            case 3:
                pack.Move(Characters.MovementWay.Left);
                break;

            case 4:
                pack.Move(Characters.MovementWay.Right);
                break;

            default:
                break;
            }
            if (pack.Location == enemy.Location)
            {
                pack.Catched(enemy);
            }
            if (_check[0] == false)
            {
                if (40 >= pack.Location.X && 40 <= (pack.Location.X + (pack.Width / 3)) && 80 >= pack.Location.Y && 80 <= ((pack.Height / 3) + pack.Location.Y))
                {
                    enemy.Location = new Point(440, 100);
                    _check[0]      = true;
                }
            }
            if (_check[1] == false)
            {
                if (480 >= pack.Location.X && 480 <= (pack.Location.X + (pack.Width / 3)) && 440 >= pack.Location.Y && 440 <= ((pack.Height / 3) + pack.Location.Y))
                {
                    enemy.Location = new Point(440, 100);
                    _check[1]      = true;
                }
            }
        }
Exemplo n.º 2
0
        private void Scene2_KeyDown(object sender, KeyEventArgs e)
        {
            Console.WriteLine($"Form1_KeyDown {e.KeyCode}");
            switch (e.KeyCode)
            {
            case Keys.W:
                pacman?.Move(Characters.MovementWay.Up);
                break;

            case Keys.S:
                pacman?.Move(Characters.MovementWay.Down);
                break;

            case Keys.A:
                pacman?.Move(Characters.MovementWay.Left);
                break;

            case Keys.D:
                pacman?.Move(Characters.MovementWay.Right);
                break;
            }
        }