示例#1
0
 public BlockableInput(BlockableInput blockableInput)
 {
     _input = blockableInput;
     blockableInput.BlockableTextEntered        += OnTextEntered;
     blockableInput.BlockableKeyPressed         += OnKeyPressed;
     blockableInput.BlockableMouseButtonDown    += OnMouseDown;
     blockableInput.BlockableMouseButtonUp      += OnMouseUp;
     blockableInput.BlockableMouseMoved         += OnMouseMoved;
     blockableInput.BlockableMouseWheelScrolled += OnMouseScrolled;
     _isControlDown = () => blockableInput.BlockedIsControlDown;
     _isShiftDown   = () => blockableInput.BlockedIsShiftDown;
 }
示例#2
0
文件: Program.cs 项目: odkken/sfcore
        static void RunCode()
        {
            var window = new RenderWindow(new VideoMode(1080, 1080), "Mirror");

            window.SetVerticalSyncEnabled(false);
            window.SetActive();
            window.Closed += (sender, eventArgs) => window.Close();

            var timeInfo = new TimeInfo();

            var globalInput = new WindowWrapperInput(window);

            globalInput.KeyPressed += args =>
            {
                if (args.Code == Keyboard.Key.Escape)
                {
                    window.Close();
                }
            };

            _terminalInput = new BlockableInput(globalInput);
            _editInput     = new BlockableInput(_terminalInput);
            _gameInput     = new BlockableInput(_editInput);

            _logger = new LambdaLogger((a, b) =>
            {
                if (b >= _logCategory)
                {
                    _terminal.LogMessage(a, b);
                }
            });

            Core.Initialize(window, timeInfo, _gameInput, new WindowUtilUtil(() => window.Size), () => _logger, new TextInfo()
            {
                DefaultFont = new Font(@"D:\git\SFCORE\SFCORE\SFCORE\Inconsolata-Regular.ttf")
            });
            InitTerminal();



            var playerShape = new CircleShape(10)
            {
                FillColor = Color.Blue
            };
            var playercontrollable = new Controllable(_gameInput);
            var player             = new Character(a => { playerShape.Position = a.ToSFVec(); return(playerShape); }, () => playercontrollable.Position);



            while (window.IsOpen)
            {
                timeInfo.Tick();
                window.DispatchEvents();
                globalInput.Update(timeInfo.CurrentDt);

                window.Clear();
                window.DispatchEvents();
                globalInput.Update(timeInfo.CurrentDt);
                playercontrollable.Update(timeInfo.CurrentDt);
                window.Clear(Color.Black);
                window.Draw(_terminal);
                window.Draw(player);
                window.Display();
            }
        }