Showing posts with label general. Show all posts
Showing posts with label general. Show all posts

Monday, November 23, 2020

Stressful period over

Sorry for going dark the past week. I was going through a stressful time this past week and was unable to focus on projects, including my personal projects. The good news is that the issue is resolved successfully as of today so I will be able to get back to my normal routine. I will be starting work on tutorials again tomorrow, not sure what yet. It will either be Eyes of the Dragon or Dragon's Claw.

Sunday, October 25, 2020

Frames Per Second Counter

So, I'm going to try something new. I'm not happy with the way it is rendering 100% but it should copy/paste fine. Most probably have one by now but I thought I'd share my frames per second component outside of a tutorial on its own. It renders the FPS into the title bar of the window and the output log in Visual Studio. I recommend using the base constructor and adding it to the list of game components in the constructor using Components.Add(new FramesPerSecond(this)).

UPDATE: I fixed the issues I had with code.


using System;
using Microsoft.Xna.Framework;

namespace Psilibrary
{
    public sealed class FramesPerSecond : DrawableGameComponent
    {
        private float _fps;
        private float _updateInterval = 1.0f;
        private float _timeSinceLastUpdate = 0.0f;
        private float _frameCount = 0;

        public FramesPerSecond(Game game)
            : this(game, false, false, game.TargetElapsedTime)
        {
        }

        public FramesPerSecond(
            Game game, 
            bool synchWithVerticalRetrace, 
            bool isFixedTimeStep, 
            TimeSpan targetElapsedTime)
            : base(game)
        {
            GraphicsDeviceManager graphics = 
                (GraphicsDeviceManager)Game.Services.GetService(
                    typeof(IGraphicsDeviceManager));

            graphics.SynchronizeWithVerticalRetrace = synchWithVerticalRetrace;
            Game.IsFixedTimeStep = isFixedTimeStep;
            Game.TargetElapsedTime = targetElapsedTime;
        }

        public sealed override void Draw(GameTime gameTime)
        {
            float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;
            _frameCount++;
            _timeSinceLastUpdate += elapsed;

            if (_timeSinceLastUpdate > _updateInterval)
            {
                _fps = _frameCount / _timeSinceLastUpdate;
                System.Diagnostics.Debug.WriteLine("FPS: " + _fps.ToString());
                Game.Window.Title = "FPS: " + ((int)_fps).ToString();
                _frameCount = 0;
                _timeSinceLastUpdate -= _updateInterval;
            }

            base.Draw(gameTime);
        }
    }
}

Wednesday, October 21, 2020

Shoot 'em Up (Shmup)

 I want to work on tutorials but I don't want these long involved tutorial series. I will still be working on the longer series but I want something shorter. For that reason I will be starting work on a Shoot 'em Up or Shmup. This will be a side scrolling game and will feature some more complex collision detection such as bounding circle, per pixel or pixel perfect collision detection. I will also be working on some other smaller games like platformers and probably a match three.

I'm planning out the next tutorial in Eyes of the Dragon. It will cover more work in the editor, saving the world from the editor and loading it back in again in the editor and the game.

Friday, October 9, 2020

Laptop Transfer

I spent most of the data transferring from my main laptop to a different laptop. I had to reinstall most of the software, transfer data and set up the environments the way that I like. It's taking a bit to get used to the new keyboard after primarily using the other for so long. I do now have everything setup the way that I like and did do some work on Silver Prophet. I did a little graphic design as well, on the loading screen. It's not finished but I like it.