Exemple #1
0
        /// <summary>
        /// The draw method for the FPSCounter. Calculates and then
        /// displays to the top-left corner of the screen.
        /// TODO: Move the spritebatch Begin() and End() calls inside?
        /// Less depending knowledge outside of how to instantiate the camera properly.
        /// </summary>
        /// <param name="gameTime">The elapsed game time, per the Game classes's Draw method.</param>
        /// <param name="spriteBatch">A primed SpriteBatch to draw with.</param>
        /// <param name="guiCamera">A camera set up to draw to regular screen coordinates.</param>
        public void Draw(GameTime gameTime, SpriteBatch spriteBatch, Camera guiCamera)
        {
            CalcFPS(gameTime);

            // Then we do our drawing.
            int i = 1;
            int frames = _lastfps;
            int currDigit = 0;
            do
            {
                currDigit = frames % 10;

                spriteBatch.Draw(
                    _numTexture,
                    new Vector2(guiCamera.Width - i * _sizeRect.Width, 0),
                    new Rectangle(_sizeRect.X + currDigit * _sizeRect.Width,
                        _sizeRect.Y,
                        _sizeRect.Width,
                        _sizeRect.Height),
                    _color,
                    0.0f,
                    new Vector2(),
                    1.0f,
                    SpriteEffects.None,
                    Layers.GUI_FPS
                );

                frames /= 10;
                i++;
            } while (frames != 0);
        }
Exemple #2
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()
        {
            // TODO: Add your initialization logic here

            // Initialize camera
            worldCamera = new WorldCamera(this.GraphicsDevice);

            guiCamera = new Camera(this.GraphicsDevice);

            base.Initialize();

            // We need to move this down because we need LoadContent to load up numbers.
            fpsCounter = new FPSCounter(numbers, new Rectangle(0, 0, 8, 10), Color.Yellow);

            // Initialize random map data for testing
            terrain = new Tilemap(1000, 1000, myTexture);
            terrain.MapFillPattern1();
        }