PyGame Basics: Drawing Images

In this tutorial, we will be walking through how to draw images with PyGame. Let’s dive right in. In your game file, you should see the set_mode method being called. This method call returns a Surface, which is pretty much just the canvas that we’re drawing to. Make sure that the return value of this method call is being assigned to a variable. I named my variable, display like to so:...

October 2, 2019 · 2 min · Jared

PyGame Basics: Game Loop

In this tutorial, we will be creating the game loop of our PyGame game. By adding the game loop, we can keep our game window from disappearing. If by chance you don’t have a game window yet, you can check out this part of our PyGame Basics series. To create our game loop, we need a clock to set the FPS, or frames-per-second of our game. Under the last line of our game window code, add the following line:...

October 1, 2019 · 2 min · Jared

PyGame Basics: Game Window

In this guide, we will be creating the PyGame game window. If you don’t have a PyGame project setup yet, you can learn how to set one up here. In your main game file, you can add the following two lines to create our game window: display = pygame.display.set_mode((800, 600)) pygame.display.set_caption('My Window Title') When you run the game, you should see a window appear for a couple seconds, then disappear. Take a look at this part of the series, where we add the game loop....

October 1, 2019 · 1 min · Jared

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 – 2

If Game1.cs is not already open in your code window, you can navigate to it via the Solution Explorer. Once Game1.cs is displayed, add the following to the using statements at the top: using Microsoft.Xna.Framework.Audio; using System.Collections.Generic; using System; We will need the audio part of MonoGame in order to load and play our sounds. We also specify that we want to use “System.Collections.Generic”. We will need this to create lists to hold objects in our game....

May 20, 2019 · 4 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