Beispiel #1
0
        //------------------------------------------------------------------------------------------------------------------------
        //														Game()
        //------------------------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="GXPEngine.Game"/> class.
        /// This class represents a game window, containing an openGL view.
        /// </summary>
        /// <param name='width'>
        /// Width of the window in pixels.
        /// </param>
        /// <param name='height'>
        /// Height of the window in pixels.
        /// </param>
        /// <param name='fullScreen'>
        /// If set to <c>true</c> the application will run in fullscreen mode.
        /// </param>
        public Game(int pWidth, int pHeight, bool pFullScreen, bool pVSync = true) : base()
        {
            if (main != null)
            {
                throw new Exception("Only a single instance of Game is allowed");
            }
            else
            {
                main              = this;
                _updateManager    = new UpdateManager();
                _collisionManager = new CollisionManager();
                _glContext        = new GLContext(this);
                _glContext.CreateWindow(pWidth, pHeight, pFullScreen, pVSync);

                //register ourselves for updates
                Add(this);
            }
        }
Beispiel #2
0
        //------------------------------------------------------------------------------------------------------------------------
        //														Game()
        //------------------------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="GXPEngine.Game"/> class.
        /// This class represents a game window, containing an openGL view.
        /// </summary>
        /// <param name='width'>
        /// Width of the window in pixels.
        /// </param>
        /// <param name='height'>
        /// Height of the window in pixels.
        /// </param>
        /// <param name='fullScreen'>
        /// If set to <c>true</c> the application will run in fullscreen mode.
        /// </param>
        public Game(int width, int height, bool fullScreen) : base()
        {
            if (main != null)
            {
                throw new Exception("Only a single instance of Game is allowed");
            }
            else
            {
                main = this;
            }
            _updateManager    = new UpdateManager();
            _collisionManager = new CollisionManager();
            _glContext        = new GLContext(this);
            _glContext.CreateWindow(width, height, fullScreen);

            if (Game.main != null)
            {
                Game.main.Add(this);
            }
        }
Beispiel #3
0
        //------------------------------------------------------------------------------------------------------------------------
        //														Game()
        //------------------------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="GXPEngine.Game"/> class.
        /// This class represents a game window, containing an openGL view.
        /// </summary>
        /// <param name='width'>
        /// Width of the window in pixels.
        /// </param>
        /// <param name='height'>
        /// Height of the window in pixels.
        /// </param>
        /// <param name='fullScreen'>
        /// If set to <c>true</c> the application will run in fullscreen mode.
        /// </param>
        public Game(int pWidth, int pHeight, bool pFullScreen, bool pVSync = true, int pRealWidth = -1, int pRealHeight = -1, bool pPixelArt = false) : base()
        {
            if (pRealWidth <= 0)
            {
                pRealWidth = pWidth;
            }
            if (pRealHeight <= 0)
            {
                pRealHeight = pHeight;
            }
            PixelArt = pPixelArt;

            if (PixelArt)
            {
                // offset should be smaller than 1/(2 * "pixelsize"), but not zero:
                x = 0.01f;
                y = 0.01f;
            }

            if (main != null)
            {
                throw new Exception("Only a single instance of Game is allowed");
            }
            else
            {
                main              = this;
                _updateManager    = new UpdateManager();
                _collisionManager = new CollisionManager();
                _glContext        = new GLContext(this);
                _glContext.CreateWindow(pWidth, pHeight, pFullScreen, pVSync, pRealWidth, pRealHeight);
                _gameObjectsContained = new List <GameObject>();

                _renderRange = new Rectangle(0, 0, pWidth, pHeight);

                //register ourselves for updates
                Add(this);
            }
        }