Getting Started


Well hello there to anyone interested in this.

Back Story

I am mainly keeping a dev blog to help keep myself motivated as I begin my Game Dev journey.

Well honestly I began my journey over 30 years ago. I remember being in 5th grade and coming up with rules to play space exploration games on paper with friends. Over the years I have poked at game development from time to time. I have tried nearly every editor here is a non-inclusive list

  • Game Maker (from version 1 all the way through Studio 2)
  • Godot
  • RenPy
  • RPG Maker (2000, 2003, MV, VX Ace, VX, XP)
  • Unity
  • Visual Novel Maker
  • Unreal Engine

While they are all amazing pieces of software none really clicked and I would just move on. A few years ago I sat down and tried MonoGame for the first time. I loved it, and I made two small classic arcade games  (snake and pong) with it.

You see I am a senior backend software engineer who develops with C# so it was a perfect fit. I got distracted with life and put it aside. Recently with over 20 years in software development, I want to try something new. I am not quitting my day job, but I want to develop something I can show off as mine. So with that decided I am getting back into game development and streaming.

Current Project

I am taking the time to learn the best practices and techniques for  game development as not all of my back end practices translate over. Also, figuring out what basics are missing that I need

So far I have implemented 3 system I feel were badly needed for any game I design with MonoGame.

https://github.com/ApocalypseTheory/TargetPractice

  1. Scene Manager
  2. Asset Manager
  3. Screen Size Change Detection

The Scene Manager

Tools/IScene.cs 
Tools/SceneManager.cs

The interface is just a common interface for all of my scenes to use to make sure they all share the same functionality.

using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace TargetPractice.Tools;
public enum SceneTypes
{
    Logo,
    MainMenu,
    Game,
    GameOver,
    Credits
}
public interface IScene
{
    event Action<SceneTypes> RequestSceneChange;
    void Initialize();
    void LoadContent();
    void Update(GameTime gameTime);
    void Draw(SpriteBatch spriteBatch);
    void OnResize(Vector2 newScreenSize);
}

The scene manager gives me a way to load a scene, change scenes, and call LoadContent, Update, Draw, and OnResize for the currently loaded scene.

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using TargetPractice.Scenes;
namespace TargetPractice.Tools;
public class SceneManager
{
    private IScene _currentScene;
    private Vector2 _currentScreenSize;
    private ResourceManager _resourceManager;
    public void ChangeScene(IScene scene)
    {
        if (_currentScene != null)
        {
            _currentScene.RequestSceneChange -= HandleSceneChange;
        }
        _currentScene = scene;
        _currentScene.Initialize();
        _currentScene?.OnResize(_currentScreenSize);
        _currentScene.RequestSceneChange += HandleSceneChange;
    }
    private void HandleSceneChange(SceneTypes sceneType)
    {
        switch (sceneType)
        {
            case SceneTypes.Logo:
                ChangeScene(new LogoScene(_resourceManager));
                break;
            case SceneTypes.MainMenu:
                //ChangeScene(new MainMenuScene(_resourceManager));
                break;
            case SceneTypes.Game:
                //ChangeScene(new GameScene(_resourceManager));
                break;
            case SceneTypes.GameOver:
                //ChangeScene(new GameOverScene(_resourceManager));
                break;
            case SceneTypes.Credits:
                //ChangeScene(new CreditsScene(_resourceManager));
                break;
        }
    }
    public void LoadContent()
    {
        _currentScene?.LoadContent();
    }
    public void Update(GameTime gameTime)
    {
        _currentScene?.Update(gameTime);
    }
    public void Draw(SpriteBatch spriteBatch)
    {
        _currentScene?.Draw(spriteBatch);
    }
    public void OnResize(Vector2 newScreenSize)
    {
        _currentScreenSize = newScreenSize;
        _currentScene?.OnResize(newScreenSize);
    }
}


This was important as it helps keep my main game loops LoadContent, Update, Draw, and OnResize clean. I did not implement Initialize since we call that on ChangeScene. Come to think of it I probably want to add that back into the IScene just to make sure ever scene has it for that reason.

Resource Manager

Tools/ResourceManager.cs

I did not want to have to load all of my assets in my main game file, or constantly pass Content and Graphics to new scenes when they are created. With that in mind I decided to set up a resource manager that could load any resources needed in my scenes.

using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
namespace TargetPractice.Tools;
public class ResourceManager
{
    private readonly ContentManager _content;
    private readonly GraphicsDevice _graphicsDevice;
    public ResourceManager(ContentManager content, GraphicsDevice graphicsDevice)
    {
        _content = content;
        _graphicsDevice = graphicsDevice;
    }
    public Texture2D LoadTexture(string path)
    {
        return _content.Load<Texture2D>(path);
    }
    public Texture2D CreateOverlayTexture()
    {
        return new Texture2D(_graphicsDevice, 1, 1);
    }
}


OnSize()

This actually lives on the SceneManager now, it just detects if the size of the game changes while playing. If so it rescales all assets to fit properly. I know its probably not needed as most games just make you restart the game, however, I like it. I will see in the future if it causes me any issues and address it then.

Next

I am stopping there with system tools. I believe those were the most critical, however, I can imagine a dozen other possible useful tools to set up before I get started. Yet I also realize that is a trap. There is no point in overengineering a game before you actually have anything that needs it. 

Over the coming weeks I plan to finish this game and work on several more as I hone my skills while I wait for my schedule to free up in Mid April where I can begin my streaming journey.

Thank you to anyone who reads this and an even bigger thank you to anyone who actually finds this interesting at all.

Feel free to visit my site directly at Apocalypse Theory

Leave a comment

Log in with itch.io to leave a comment.