The World Of Nick

My Thoughts On XNA | Tuesday, April 22nd, 2025

This article is just me talking a little bit about XNA.

Preface

This guide won't be the best, this is my first real 'guide' so I'll improve as I make more. I am trying to get more fimilar with XNA so I can make a 3D games and my first 'real' game. So far this is my 5th game that I have decided to work on! I didn't use any LLMs or whatever bullshit, since the goal is for me to get gud as they they say.

In this guide I'll be teaching you how to make a Doodle Jump like game, will it be 100% accurate, no. Is the game programmed like this, I do not know.

Anyways, this guide should work for Windows, MacOS and Linux programmers, FreeBSD probbaly would work with the Linuxulator (maybe, I really do not know).

This expects you know a little bit about programming, like the basic terms of classes, intgers, etc. But you don't have to be a 30 senior dev to follow this (lord knows I am not one).

I have sorted some words, in sompe places to save space. So GraphicsDeviceManager is GDM, SpriteBatch is SB.

I used MonoGame, however this should work the same for FNA and XNA expect some minor differences.

Getting Started!

So, I was orginnaly going to talk about how to install dotnet, momogame, etc but well just folow this guide, this should cover installing MonoGame.

So we need to create a MonoGame project, we'll be using the Desktop OpenGL project, this support Windows, Mac, and Linux. If you're on Windows you can also use desktop-gx, but desktop-gl is better. The only difference for you the dev is how shaders and effects are programmed (but we do not those). But just use desktop-gl, okay?

Run this (-n just speificies your of your game) your terminal, cmd, etc.

                               dotnet new mgdesktopgl -n DaleJump
                            

Open it with whatever editor you want to use, I use vs-codiuim, but you can use neo-vim, notepad++, whatever

And onto the game proper!

Creating The Platfrom Logic

Now I tend to prefer to start with the game envierment, before making a player. So that's we are doing.

For now we are going to stick with untextured sprites, we we'll need to make a Texture2D and then set that to the colour white, and make it 1x1. This will be used when we draw the platfroms. We'll also delcare the game res we want (I just did 800x600).

              
                                private GraphicsDeviceManager _graphics;
                                private SpriteBatch _spriteBatch; 
                                
                                public Texture2D blankTexture;// I prefer to declare textures under SB and GDM, but you do you!
                               
                                int gameResWidth = 800;
                                int gameResHeight = 600;

                            


                    			public Game1()
                                {
                                    _graphics = new GraphicsDeviceManager(this);
                            
                                    _graphics.PreferredBackBufferWidth = gameResWidth;
                                    _graphics.PreferredBackBufferHeight = gameResHeight;
                                    
                                    Content.RootDirectory = "Content";
                                    IsMouseVisible = true;
                                }
                            


                                protected override void LoadContent()
                                {
                                    _spriteBatch = new SpriteBatch(GraphicsDevice);
                                    
                                    blankTexture = new Texture2D(GraphicsDevice, 1, 1);
                                    blankTexture.SetData(new[] { Color.White }); 
                                    
                                }
                            


Now we have a texture!