コード例 #1
0
ファイル: Program.cs プロジェクト: TwoFX/firework-engine
        static void Main(string[] args)
        {
            //System.Threading.Thread msgLoop = new System.Threading.Thread(new System.Threading.ThreadStart())

            TetrisField field = new TetrisField();
            Timer gameTimer = new Timer(1000);
            gameTimer.Elapsed += (sender, e) =>
                {
                    field.Gravity();
                    UIManager.Render();
                    UIManager.DrawFrame();
                };
            gameTimer.Start();

            Display disp = new Display(field.Next);
            field.TetrominoLocked += (sender, e) => disp.Update(e.Next);

            Display held = new Display(field.Hold);
            field.TetrominoHeld += (sender, e) => held.Update(e.Hold);

            //UIThread.Start();

            UIScene scene = new UIScene(new IRenderable[] { field, disp, held }, new[] { new[] { 1, 1 }, new[] { 1, 22 }, new[] {10, 22}}, new[] { "Field", "Next", "Hold"}, 42, 31, ConsoleColor.White, ConsoleColor.White);
            UIManager.Initialize();
            UIManager.setScene(scene);
            while (true)
            {
                UIManager.Render();
                UIManager.DrawFrame();
                ConsoleKeyInfo k = Console.ReadKey(false);
                if (k.Key == ConsoleKey.LeftArrow)
                {
                    field.ProcessInput(UserInput.Left);
                }
                else if (k.Key == ConsoleKey.RightArrow)
                {
                    field.ProcessInput(UserInput.Right);
                }
                else if (k.Key == ConsoleKey.UpArrow)
                {
                    field.ProcessInput(UserInput.RotateClockwise);
                }
                else if (k.Key == ConsoleKey.DownArrow)
                {
                    field.ProcessInput(UserInput.Down);
                }
                else if (k.Key == ConsoleKey.Spacebar)
                {
                    field.ProcessInput(UserInput.Lock);
                }
                else if (k.Key == ConsoleKey.A)
                {
                    field.ProcessInput(UserInput.Hold);
                }
            }
            Console.ReadKey(true);
        }
コード例 #2
0
ファイル: UIManager.cs プロジェクト: TwoFX/firework-engine
 public static void setScene(IRenderable newScene)
 {
     if (newScene.GetType() == typeof(UIScene))
     {
         currentElement = (UIScene)newScene;
     }
     else
     {
         currentElement = new UIScene(new IRenderable[] { newScene }, new int[][] { new int[] { 1, 1 } }, new string[] { "" }, newScene.Height + 2, newScene.Width + 2);
     }
     Console.WindowWidth = currentElement.Width;
     Console.WindowHeight = currentElement.Height + 1;
     //Console.BufferHeight = currentElement.Height + 1;
     //Console.BufferWidth = currentElement.Width + 1;
     Console.SetBufferSize(currentElement.Width + 1, currentElement.Height + 1);
 }
コード例 #3
0
ファイル: Program.cs プロジェクト: TwoFX/firework-engine
        static void MainTest()
        {
            UIScene currentElement;
            Table myElement, myOtherElement, ThirdElement;
            FW.Buffer buffer;
            ProgressBar pb;

            UIManager.Initialize(ConsoleColor.White);

            myElement = new Table(new string[][] {new string[] {
                "Left 1", "Right 1"},
                new string[] {"Left 2", "Right 2"},
                new string[] {"Left 3", "Right 3 Looong"},
                new string[] {"Left 444444554545454444", "t"},
                new string[] {"i", "asdasdasdasdasdasdasdasd"},
                new string[] {"Level", "9001"}}, 30, null, ConsoleColor.Red, TableMode.LeftHeader);

            myOtherElement = new Table(new string[][] { // So sieht der Quellcode aus
                new string[] {"This", "Here"},
                new string[] {"is", "be"},
                new string[] {"the", "data"},
                new string[] {"title", "00"},
                new string[] {"line", "000"},
                new string[] {"!", "0000"}}, 30, null, ConsoleColor.Red, TableMode.LeftHeader);

            ThirdElement = new Table(new string[][] {new string[] {
                "Name", "OP"},
                new string[] {"OP?", "OP"},
                new string[] {",,,,,,,,", "......"},
                new string[] {"       Needs trimming", "9002"},
                new string[] {"Intelligenz", "Really does                   "},
                new string[] {"Level", "Colorful console game thingy"}}, 61, null, ConsoleColor.Red, TableMode.TopHeader);

            pb = new ProgressBar(0, 61);

            currentElement = new UIScene(new IRenderable[] { myElement, myOtherElement, ThirdElement, pb },
                new int[][] { new int[] { 1, 1 }, new int[] { 1, 32 }, new int[] { 8, 1 }, new int[] { 15, 1 } },
                new string[] { "Spieler 1", "Spieler 2", "OMG Gegner", "Progress" }, 17, 63, ConsoleColor.Green, null);

            UIManager.setScene(currentElement);

            UIManager.Render();
            UIManager.DrawFrame();

            Console.ReadKey();

            pb.Update(0.5);
            UIManager.Render();
            UIManager.DrawFrame();
            Console.ReadKey();

            pb.Update(0.3);
            UIManager.Render();
            UIManager.DrawFrame();
            Console.ReadKey();

            pb.Update(1);
            UIManager.Render();
            UIManager.DrawFrame();
            Console.ReadKey();

            currentElement = new UIScene(new IRenderable[] { myOtherElement, myElement, ThirdElement },
                new int[][] { new int[] { 1, 1 }, new int[] { 1, 32 }, new int[] { 8, 1 } },
                new string[] { "Spieler 1", "Spieler 2", "OMG Gegner" }, 15, 63, ConsoleColor.Green, null);

            UIManager.setScene(currentElement);

            UIManager.Render();
            UIManager.DrawFrame();

            Console.ReadKey();

            buffer = new FW.Buffer(myElement, new FireworkEngine.Margin { Top = 3, Left = 6, Bottom = 3, Right = 7 }, ' ');
            currentElement = new UIScene(new[] { buffer }, new[] { new[] { 1, 1 } }, new[] { "Buffer Test" }, 14, 45);

            UIManager.setScene(currentElement);

            UIManager.Render();
            UIManager.DrawFrame();

            Console.ReadKey();
        }