Build a Space Shooter with MonoGame – 6

Now that we’re done with the classes for our game object’s, let’s create one more class for our menu buttons. Add a new class named MenuButton.cs. In that class, add the usual two using statements. This class does not need to extend anything. Next, add the following fields and properties: private Game1 game; private Vector2 position; private Texture2D texDefault; private Texture2D texOnDown; private Texture2D texOnHover; private Texture2D currentTexture; public Rectangle boundingBox; public bool isActive { get; set; } public bool lastIsDown = false; private bool _isDown = false; private bool _isHovered = false; Then we will add two methods for setting whether the button is pushed down or not, and whether the mouse is hovering over the button or not....

May 20, 2019 · 9 min · Jared

Build a Space Shooter with MonoGame – 4

Next let’s create a new class named Entity.cs. The player spaceship and any other enemies in the game with inherit the properties of this class. In our new Entity class, add a using statement for Microsoft.Xna.Framework. Every entity will store the following information: is rotatable, scale, position, source origin, destination origin, and physics body. Add the following to initialize these fields and properties: protected bool isRotatable = false; public Vector2 scale = new Vector2(1....

May 20, 2019 · 9 min · Jared

Build a Space Shooter with MonoGame – 3

Now, we know every game worth it’s money has a game state system of some sort. I mean this as in, most games have a main menu, a play state, and a game over state. Something like that. We will have to build this sort of system. For this, we will be utilizing the enum type in C#. Just after where we initialize the field arialHeading, add the following to define an enum named GameState:...

May 20, 2019 · 5 min · Jared

Build a Space Shooter with MonoGame – 1

INTRODUCTION In this course, we will be creating a space shoot-em-up game with MonoGame! MonoGame is an open-source implementation of XNA, and has a very active community surrounding it. Before we get started, it will be important that you have MonoGame installed. If you need to install MonoGame on Windows, you can check out our installation guide, otherwise the installers for other platforms should be similar. If you are using Mac OS or Linux, you can find the download links on this page (for version 3....

May 20, 2019 · 4 min · Jared

Build a Space Shooter with MonoGame – 5

The last two classes we’ll add will be devoted to the scrolling background system. Create a new class, and name it ScrollingBackground.cs. This class does not __need to inherit anything. It will still need the two usual using statements. We will want to add two fields containing background textures and layers: private List<Texture2D> textures = new List<Texture2D>(); private List<ScrollingBackgroundLayer> layers = new List<ScrollingBackgroundLayer>(); The step is to add the constructor. We will be creating a vertical “stack” of three backgrounds, but we’ll be creating two more layers of backgrounds on top....

May 20, 2019 · 4 min · Jared

Setting up MonoGame on Windows

MonoGame is the most powerful frameworks for creating cross-platform games. One of the great features about it, is that it’s open-source. If you ever need to adjust something within the framework itself, you can do it. The MonoGame community is a very active community with hobbyists and professionals alike. The purpose of this guide is to help you setup MonoGame if want to use Windows for game development. Before installing MonoGame, we will need to install Visual Studio 2017....

April 30, 2019 · 1 min · Jared