protected override void Initialize()
 {
     try
     {
         Perf.Time($"{nameof(NeedlesslyComplexMainGame)}.Initialize", () =>
         {
             CurrentGame.Init(this);
             Resources.Init();
             // @todo #1 Bug: Update the GraphicsDeviceManager in the constructor, to avoid the window being mispositioned and visibly changing size
             CurrentDisplay.Init(_graphics, _display);
             Window.Position = new Point((GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width - CurrentDisplay.GameWidth) / 2,
                                         (GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height - CurrentDisplay.GameHeight) / 2 - 40); // Delete this once the above issue is fixed
             IsMouseVisible    = true;
             _uiSpriteBatch    = new SpriteBatch(GraphicsDevice);
             _worldSpriteBatch = new SpriteBatch(GraphicsDevice);
             Input.SetController(_controller);
             World.Init(_worldSpriteBatch);
             UI.Init(_uiSpriteBatch);
             _scene.Init();
             base.Initialize();
         });
     }
     catch (Exception e)
     {
         _errorHandler.Handle(new Exception("Error while Initializing MonoDragons Core engine", e));
     }
 }
Example #2
0
 private void InitDisplayIfNeeded()
 {
     if (!_areScreenSettingsPreCalculated)
     {
         var widthScale  = (float)GraphicsDevice.DisplayMode.Width / _defaultScreenSize.Width;
         var heightScale = (float)GraphicsDevice.DisplayMode.Height / _defaultScreenSize.Height;
         var scale       = widthScale > heightScale ? heightScale : widthScale;
         _display = new Display((int)Math.Round(_defaultScreenSize.Width * scale), (int)Math.Round(_defaultScreenSize.Height * scale),
                                true, scale);
     }
     CurrentDisplay.Init(_display);
 }
Example #3
0
 protected override void Initialize()
 {
     Perf.Time($"{nameof(NeedlesslyComplexMainGame)}.Initialize", () =>
     {
         CurrentGame.Init(this);
         Resources.Init();
         InitDisplayIfNeeded();
         // @todo #1 Bug: Update the GraphicsDeviceManager in the constructor, to avoid the window being mispositioned and visibly changing size
         CurrentDisplay.Init(_graphics, _display);
         Window.Position = new Point(0, 0); // Delete this once the above issue is fixed
         IsMouseVisible  = true;
         _sprites        = new SpriteBatch(GraphicsDevice);
         Input.SetController(_controller);
         World.Init(_sprites);
         UI.Init(_sprites);
         _scene.Init();
         base.Initialize();
     });
 }