Beispiel #1
0
        private void UpdateLoop()
        {
            if (!game.paused)
            {
                game.Iterate();
            }

            var focused = false;

            Invoke((MethodInvoker)(() => { focused = Focused; }));
            if (focused)
            {
                if (Keyboard.IsKeyDown(Keyboard.Key.D))
                {
                    game.SetBorderType(Grid.BorderType.DeadBorders);
                    canvas.DrawBorders(colors["gray 24"]);
                }

                if (Keyboard.IsKeyDown(Keyboard.Key.L))
                {
                    game.SetBorderType(Grid.BorderType.LiveBorders);
                    canvas.DrawBorders(colors["white"]);
                }

                if (Keyboard.IsKeyDown(Keyboard.Key.W))
                {
                    game.SetBorderType(Grid.BorderType.WrapBorders);
                    canvas.DrawBorders(colors["gray 64"]);
                }

                if (Keyboard.IsKeyDown(Keyboard.Key.R))
                {
                    game.Randomize(D);
                }

                if (Keyboard.IsKeyDown(Keyboard.Key.C))
                {
                    game.Clear();
                }

                if (Keyboard.IsKeyDown(Keyboard.Key.RIGHT))
                {
                    if (game.paused)
                    {
                        game.Iterate();
                    }
                    else
                    {
                        game.paused = true;
                    }
                }

                if (Keyboard.IsKeyDown(Keyboard.Key.LEFT))
                {
                    if (game.paused)
                    {
                        game.Undo();
                    }
                    else
                    {
                        game.paused = true;
                    }
                }

                if (Keyboard.IsKeyDown(Keyboard.Key.SPACE))
                {
                    game.paused = !game.paused;
                }
            }
        }