public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            graphics.IsFullScreen = false;

            _circle1 = new Circle();
            _circle2 = new Circle();

            _clock = new GameClock();

            //Setup the input for this game.
            _inputState             = new InputState();
            Mappings.UseKeyboard[0] = true;             //Set the first player to use the keyboard.
            _controller             = new ControllerWrapper(0);
            _inputWrapper           = new InputWrapper(_controller, _clock.GetCurrentTime);


            var resolution = new ResolutionComponent(this,
                                                     graphics,
                                                     new Point(1280, 720), //The desired virtual resolution that items in the game will be drawn with
                                                     new Point(1280, 720), //The desired physical resolution to set the screen.
                                                     false,                //Flag whether or not to fullscreen the app
                                                     true,                 //Flag whether or not to letterbox the app to fit the aspect ratio of virtual/screen resolutions.
                                                     false);               //This flag can be used to set it to use the entire screen BUT without setting the Device.Fullscreen flag.

            //set up the camera
            _camera = new Camera();

            //The WorldBoundary is a rectangle that the Camera will try to stay inside. When the circle moves out of this rectangle it will appear to go offscreen.
            _camera.WorldBoundary = new Rectangle(0, 0, 1280, 720);
        }
示例#2
0
 public void ResetResolution(Point size)
 {
     game.Components.Remove(resolution);
     game.Services.RemoveService(typeof(IResolution));
     resolution = null;
     resolution = new ResolutionComponent(game, game.Graphics, new Point(1920, 1080), size, false, true);
     CamManager.Instance.RecalculateTransformationMatrices();
 }
示例#3
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            ResolutionComponent = new ResolutionComponent(this, Graphics, VirtualResolution, ScreenResolution, Fullscreen, Letterbox);
            InitStyles();

            // Create the screen manager component.
            ScreenManager = new ScreenManager(this, GetMainMenuScreenStack);

            base.Initialize();
        }
示例#4
0
        public void CreateResolution(GameSettings settings)
        {
            //Recreation of the resolution
            if (_resolution != null)
            {
                _game.Components.Remove(_resolution);
                _game.Services.RemoveService(typeof(IResolution));
            }
            _game.Window.IsBorderless    = true;
            _graphics.HardwareModeSwitch = true;
            _game.IsFixedTimeStep        = false; // Setting this to true makes it fixed time step, false is variable time step.
            _game.IsMouseVisible         = true;
            //Check if resolution is supported
            bool resolutionIsSupported = false;

            foreach (DisplayMode displayMode in GraphicsAdapter.DefaultAdapter.SupportedDisplayModes)
            {
                if (settings.GetWidth() == displayMode.Width && settings.GetHeight() == displayMode.Height)
                {
                    resolutionIsSupported = true;
                    break;
                }
            }
            // Change Virtual Resolution
#if DEBUG
            if (resolutionIsSupported)
            {
                _resolution = new ResolutionComponent(_game, _graphics, new Point(1920, 1080), new Point(settings.GetWidth(), settings.GetHeight()), settings.GetFullscreen(), true);
            }
            else
            {
                _resolution = new ResolutionComponent(_game, _graphics, new Point(1920, 1080), new Point(GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width, GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height), settings.GetFullscreen(), true);
            }
#else
            if (resolutionIsSupported)
            {
                _resolution = new ResolutionComponent(_game, _graphics, new Point(1920, 1080), new Point(settings.GetWidth(), settings.GetHeight()), settings.GetFullscreen(), true);
            }
            else
            {
                _resolution = new ResolutionComponent(_game, _graphics, new Point(1920, 1080), new Point(GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width, GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height), settings.GetFullscreen(), true);
            }
#endif
        }
示例#5
0
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            graphics.IsFullScreen = false;

            var resolution = new ResolutionComponent(this, graphics, new Point(1280, 720), new Point(1280, 720), false, true);

            _circle1 = new Circle();
            _circle2 = new Circle();

            _clock        = new GameClock();
            _inputState   = new InputState();
            _controller   = new ControllerWrapper(PlayerIndex.One, true);
            _inputWrapper = new InputWrapper(_controller, _clock.GetCurrentTime);

            //set up the camera
            _camera               = new Camera();
            _camera.TopPadding    = 0.2f;
            _camera.WorldBoundary = new Rectangle(-2000, -1000, 4000, 2000);
        }
示例#6
0
 public ResolutionManager()
 {
     game       = GameRoot.Instance;
     resolution = new ResolutionComponent(game, GameRoot.Instance.Graphics, new Point(1920, 1080), GetDisplay(), false, true);
 }