Exemple #1
0
        static void Main(string[] args)
        {
            ObjectDictionary objectDictionary = new ObjectDictionary();


            int intX = 12;
            int intY = 12;


            bool on = true;

            Object objectPoint = new Object();

            objectPoint.intIndex = 1;


            objectPoint.arrayApearance.Add(new PairOrdenated(0, 0), 10);


            //objectPoint.arrayApearance.Add(new PairOrdenated(-1, 0), 0);
            //objectPoint.arrayApearance.Add(new PairOrdenated(1, 0), 0);
            //objectPoint.arrayApearance.Add(new PairOrdenated(0, -1), 0);
            //objectPoint.arrayApearance.Add(new PairOrdenated(0, 1), 0);
            objectPoint.arrayColisionMesh = new PairOrdenated[] { new PairOrdenated(0, 0) };
            objectPoint.pairPosition      = new PairOrdenated(2, 2);


            int intSpeedX = 1;
            int intSpeedY = 1;

            Object objectWall = new Object();

            //Pontos para fazer o array Wall
            objectWall.arrayApearance.Add(new PairOrdenated(0, 0), 12); // Cor (Vermelho)
            objectWall.arrayApearance.Add(new PairOrdenated(0, 1), 15); // Cor (Branco)
            objectWall.arrayApearance.Add(new PairOrdenated(0, 2), 12); // Cor (Vermelho)

            objectWall.arrayColisionMesh = new PairOrdenated[] { new PairOrdenated(0, 0), new PairOrdenated(0, 1), new PairOrdenated(0, 2) };

            // Fim desses pontos

            objectWall.intIndex     = 2;
            objectWall.pairPosition = new PairOrdenated(5, 5);

            int origX = Console.CursorTop;
            int origY = Console.CursorLeft;

            objectDictionary.Add(objectDictionary, objectWall);
            objectDictionary.Add(objectDictionary, objectPoint);


            while (on)
            {
                Console.CursorVisible = false;

                objectPoint.pairSpeed.intX = 0;
                objectPoint.pairSpeed.intY = 0;

                if (Console.KeyAvailable == true)
                {
                    ConsoleKeyInfo keyPressed = Console.ReadKey(true);

                    if (keyPressed.Key == ConsoleKey.S)
                    {
                        objectPoint.pairSpeed.intY = 1 * intSpeedY;
                        objectPoint.pairSpeed.intX = 0;
                    }

                    else if (keyPressed.Key == ConsoleKey.W)
                    {
                        objectPoint.pairSpeed.intY = -1 * intSpeedY;
                        objectPoint.pairSpeed.intX = 0;
                    }
                    else if (keyPressed.Key == ConsoleKey.D)
                    {
                        objectPoint.pairSpeed.intX = 1 * intSpeedX;
                        objectPoint.pairSpeed.intY = 0;
                    }
                    else if (keyPressed.Key == ConsoleKey.A)
                    {
                        objectPoint.pairSpeed.intX = -1 * intSpeedX;
                        objectPoint.pairSpeed.intY = 0;
                    }
                } // Ler o teclado

                Object.Transform(objectPoint, objectWall);


                ImageBuffer imageBuffer = new ImageBuffer();
                imageBuffer.ImageBuffering(imageBuffer, objectDictionary);
                imageBuffer.ConsoleImageProjector(imageBuffer);


                Console.SetCursorPosition(origX + intX, origY + intY);
                Console.BackgroundColor = ConsoleColor.Black;

                Console.WriteLine();
                Console.Write($"X: {objectPoint.pairPosition.intX} Y: {objectPoint.pairPosition.intY}");
                Console.Write($"Speed: X= {objectPoint.pairSpeed.intX} Y= {objectPoint.pairSpeed.intY}");
                Console.WriteLine();
            }
        }