Пример #1
0
        // ReSharper disable once MemberCanBeProtected.Global
        public WinFormGame()
        {
            Random = new Random(DateTime.Now.Millisecond);
            SetBounds(300, 300, 500, 500);
            FormBorderStyle = FormBorderStyle.FixedSingle;
            // ReSharper disable once VirtualMemberCallInConstructor
            DoubleBuffered = true;
            MaximizeBox    = false;

            Icon = (System.Drawing.Icon) new ComponentResourceManager(typeof(Icon)).GetObject("icon");

            _syncContext = SynchronizationContext.Current;
            _gamePanel   = new AbstractGame
            {
                OnClickAction = e => OnClick(e, Mouse),
                OnCustomDraw  = OnCustomDraw
            };

            FormClosing += OnExit;

            // ReSharper disable once VirtualMemberCallInConstructor
            OnInit();
            _gamePanel.SetBounds(0, 0, Width, Height);
            Controls.Add(_gamePanel);
            Show();
            Run();
            // ReSharper disable VirtualMemberCallInConstructor
        }
Пример #2
0
 public Game()
 {
     _timer    = new FTimer(10);
     GamePanel = new AbstractGame();
     OnInit();
     GamePanel.SetBounds(0, 0, Width, Height);
     Controls.Add(GamePanel);
     Show();
     Run();
     // ReSharper disable VirtualMemberCallInConstructor
 }