public PruebaPacMan()
 {
     fantasmas    = new Fantasma[4];
     fantasmas[0] = new FantasmaRojo(15, 11);
     fantasmas[1] = new FantasmaNaranja(17, 12);
     fantasmas[2] = new FantasmaRosa(19, 13);
     fantasmas[3] = new FantasmaAzul(21, 14);
     nivel        = new Nivel();
 }
示例#2
0
    static void Main()
    {
        Pac p = new Pac(13, 10);

        p.Mostrar();
        p.Mover();
        Fantasma[] fantasmas = new Fantasma[4];
        fantasmas[0] = new FantasmaRojo(15, 11);
        fantasmas[1] = new FantasmaNaranja(17, 12);
        fantasmas[2] = new FantasmaRosa(19, 13);
        fantasmas[3] = new FantasmaAzul(21, 14);

        for (int i = 0; i < fantasmas.Length; i++)
        {
            fantasmas[i].Mostrar();
            fantasmas[i].Mover();
        }
    }
    static void Main()
    {
        bool salir = false;

        Pac p = new Pac(13, 10);

        p.Mostrar();
        p.Mover();
        Fantasma[] fantasmas = new Fantasma[4];
        fantasmas[0] = new FantasmaRojo(15, 11);
        fantasmas[1] = new FantasmaNaranja(17, 12);
        fantasmas[2] = new FantasmaRosa(19, 13);
        fantasmas[3] = new FantasmaAzul(21, 14);

        do
        {
            p.Mostrar();

            for (int i = 0; i < fantasmas.Length; i++)
            {
                fantasmas[i].Mostrar();
            }

            ConsoleKeyInfo tecla = Console.ReadKey();

            switch (tecla.Key)
            {
            case ConsoleKey.Escape:
                salir = true;
                break;

            case ConsoleKey.LeftArrow:
                p.X--;
                break;

            case ConsoleKey.RightArrow:
                p.X++;
                break;

            case ConsoleKey.UpArrow:
                p.Y--;
                break;

            case ConsoleKey.DownArrow:
                p.Y++;
                break;

            default:
                break;
            }
            foreach (Fantasma f in fantasmas)
            {
                f.Mover();
            }

            Console.Clear();

            foreach (Fantasma f in fantasmas)
            {
                f.Mostrar();
            }

            p.Mostrar();
        }while (!salir);
    }
示例#4
0
    static void Main()
    {
        bool  salir = false;
        Nivel n     = new Nivel();

        n.CrearLaberinto();
        n.Mostrar();
        n.MostrarMarcador();

        Pac p = new Pac(7, 5);

        p.Mostrar();
        p.Mover();
        Fantasma[] fantasmas = new Fantasma[4];
        fantasmas[0] = new FantasmaRojo(2, 1);
        fantasmas[1] = new FantasmaNaranja(10, 8);
        fantasmas[2] = new FantasmaRosa(11, 1);
        fantasmas[3] = new FantasmaAzul(13, 7);
        do
        {
            n.Mostrar();
            n.MostrarMarcador();
            p.Mostrar();

            for (int i = 0; i < fantasmas.Length; i++)
            {
                fantasmas[i].Mostrar();
            }

            ConsoleKeyInfo tecla = Console.ReadKey();

            switch (tecla.Key)
            {
            case ConsoleKey.Escape:
                salir = true;
                break;

            case ConsoleKey.LeftArrow:
                if (n.EsPosibleMoverA(p.X - 1, p.Y))
                {
                    p.X--;
                }
                n.ObtenerPuntosDe(p.X, p.Y);
                break;

            case ConsoleKey.RightArrow:
                if (n.EsPosibleMoverA(p.X + 1, p.Y))
                {
                    p.X++;
                }
                n.ObtenerPuntosDe(p.X, p.Y);
                break;

            case ConsoleKey.UpArrow:
                if (n.EsPosibleMoverA(p.X, p.Y - 1))
                {
                    p.Y--;
                }
                n.ObtenerPuntosDe(p.X, p.Y);
                break;

            case ConsoleKey.DownArrow:
                if (n.EsPosibleMoverA(p.X, p.Y + 1))
                {
                    p.Y++;
                }
                n.ObtenerPuntosDe(p.X, p.Y);
                break;

            default:
                break;
            }

            for (int i = 0; i < fantasmas.Length; i++)
            {//Falta depurar movimiento de fantasmas
                if (n.EsPosibleMoverA(fantasmas[i].X, fantasmas[i].Y + 1))
                {
                    fantasmas[i].MoverAbajo();
                }
                else if (n.EsPosibleMoverA(fantasmas[i].X, fantasmas[i].Y - 1))
                {
                    fantasmas[i].MoverArriba();
                }
                else if (n.EsPosibleMoverA(fantasmas[i].X + 1, fantasmas[i].Y))
                {
                    fantasmas[i].MoverIzquierda();
                }
                else if (n.EsPosibleMoverA(fantasmas[i].X - 1, fantasmas[i].Y))
                {
                    fantasmas[i].MoverDerecha();
                }
            }
            Console.Clear();

            foreach (Fantasma f in fantasmas)
            {
                f.Mostrar();
            }

            n.Mostrar();
            p.Mostrar();

            for (int i = 0; i < fantasmas.Length; i++)
            {
                if (p.X == fantasmas[i].X && p.Y == fantasmas[i].Y)
                {
                    salir = true;
                }
            }

            if (salir)
            {
                Console.WriteLine("TE HA COMIDO EL FANTASMA!");
            }
        }while (!salir);
        Console.SetCursorPosition(5, 12);
        Console.WriteLine("FIN DE LA PARTIDA!");
    }