Esempio n. 1
0
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            ManageResolution.Init(ref graphics);
            ManageResolution.SetVirtualResolution(480, 270);
            ManageResolution.SetResolution(1920, 1080, false);

            IsFixedTimeStep = false;

#if DEBUG
            PlayerStats.StartWithUpgrades();
#endif
        }
Esempio n. 2
0
        static public void Draw(SpriteBatch spriteBatch)
        {
            if (_healthBar == null || _healthUnit == null)
            {
                return;
            }
            var _player = PlayerController.Player;

            if (_player == null)
            {
                return;
            }

            spriteBatch.Begin(SpriteSortMode.FrontToBack,
                              BlendState.AlphaBlend,
                              SamplerState.PointClamp,
                              null,
                              null,
                              null,
                              ManageResolution.GetTransformationMatrix());

            spriteBatch.Draw(_healthBarExtender, new Vector2(16, 40 - (4 * (PlayerStats.MaxHealth - 12))), null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0.2f);
            spriteBatch.Draw(_healthBar, new Vector2(16, 40), null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, .1f);


            for (int i = 0; i < PlayerCurrentHealth; i++)
            {
                spriteBatch.Draw(_healthUnit, new Vector2(16 + (4), 49 + 40 - (4 * i)), null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0.3f);
            }

            if (ManageInput.GamePaused)
            {
                spriteBatch.Draw(_pauseTexture, new Rectangle(0, 0, ManageResolution.VirtualWidth, ManageResolution.VirtualHeight), new Color(Color.Black, _alpha));
            }

            if (ManageInput.GamePaused)
            {
                _manageMenu.Draw(spriteBatch);
            }

            spriteBatch.End();
        }
Esempio n. 3
0
        private static void CalculateMatrixAndRectangle()
        {
            //The math involved with calculated our transformMatrix and screenRect is a little intense, so instead of calling the math whenever we need these variables,
            //we'll calculate them once each frame and store them... when someone needs these variables we will simply return the stored variable instead of re cauclating them every time.

            //Calculate the camera transform matrix:
            transformMatrix = Matrix.CreateTranslation(new Vector3(-position, 0)) * Matrix.CreateRotationZ(rotation) *
                              Matrix.CreateScale(new Vector3(zoom, zoom, 1)) * Matrix.CreateTranslation(new Vector3(ManageResolution.VirtualWidth
                                                                                                                    * 0.5f, ManageResolution.VirtualHeight * 0.5f, 0));

            //Now combine the camera's matrix with the Resolution Manager's transform matrix to get our final working matrix:
            transformMatrix = transformMatrix * ManageResolution.GetTransformationMatrix();

            //Round the X and Y translation so the camera doesn't jerk as it moves:
            transformMatrix.M41 = (float)Math.Round(transformMatrix.M41, 0);
            transformMatrix.M42 = (float)Math.Round(transformMatrix.M42, 0);

            //Calculate the rectangle that represents where our camera is at in the world:
            screenRect = VisibleArea();
        }
Esempio n. 4
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            _fpsCounter++;
            _counterElapsed += gameTime.ElapsedGameTime;

            if (_counterElapsed >= TimeSpan.FromSeconds(1))
            {
#if DEBUG
                Window.Title = "FULL MOON " + _fpsCounter.ToString() + "fps - " +
                               (GC.GetTotalMemory(false) / 1048576f).ToString("F") + "MB";
#endif
                _fpsCounter      = 0;
                _counterElapsed -= TimeSpan.FromSeconds(1);
            }

            // TODO: Add your drawing code here

            ManageResolution.BeginDraw();
            _manageScreens.Draw(spriteBatch);
            base.Draw(gameTime);
        }