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