Esempio n. 1
0
        static void Main(string[] args)
        {
            //RunTest();

            var mainFrame = new Frame("main", 22, 22)
            {
                Row = 1,
                Col = 27
            };


            var messageFrame = new Frame("messages", 3, 17)
            {
                Row = 1,
                Col = 1
            };

            var message = new Sprite(1, 15)
            {
                Row = 1,
                Col = 1
            };

            messageFrame.Sprites.Add(message);

            IBlock block = new Pillar();

            mainFrame.Add(block);

            var screen = new Screen();

            screen.Add(mainFrame);
            screen.Add(messageFrame);

            var loop = true;

            while (loop)
            {
                var projectionSucceeded = screen.Project((c, cols) =>
                {
                    message.PrintH(0, 0, "Collision!", ConsoleColor.Red);
                    block.Undo();
                    return(false);
                });

                if (!projectionSucceeded)
                {
                    screen.Project();
                }

                var keyInfo = Console.ReadKey(true);
                switch (keyInfo.KeyChar)
                {
                case 'w': block.Rotate(); break;

                case 's': block.MoveDown(); break;

                case 'a': block.MoveLeft(); break;

                case 'd': block.MoveRight(); break;

                case 'r': screen.Refresh(); break;

                case 'q': loop = false; break;
                }
                message.Clear();
            }
        }