PyGame Basics

PyGame Basics: Grouping Game Objects

PyGame Basics: Grouping Game Objects

In this guide, we will be taking a look at grouping game objects with PyGame. This is useful because most likely you will want to add or remove objects of the same type. Simply using variables to reference objects with won't cut it. You might use a variable for...

PyGame Basics: An Improved Game Loop

PyGame Basics: An Improved Game Loop

In this guide, we will be creating a PyGame game loop with delta time. Using delta time can be very useful in keeping the movement of your game smoother. Essentially with a delta time based game loop, game objects will appear to move at a constant speed even when the...

PyGame Basics: Keyboard Input

PyGame Basics: Keyboard Input

In this guide, we will take a look at a couple ways to gather keyboard input with PyGame. There are a few ways of grabbing keyboard input. The first way to gather keyboard input is via capturing PyGame events. To check if any arrow keys are pressed down on the current...

PyGame Basics: Mouse Input

PyGame Basics: Mouse Input

In this guide, we will be taking a look at how to utilize mouse input with PyGame. Mouse Position To retrieve the position of the mouse, you can use the following line: mousex, mousey = pygame.mouse.get_pos() Of course, with the above line, you can access the x...

PyGame Basics: Image Effects

PyGame Basics: Image Effects

In this guide, we will be taking a look at some different image effects you can use within your PyGame. In the examples below, I will be drawing sample images at x: 480 and y: 128. To learn how to position images, you can take a look at this guide of ours. Scaling...

PyGame Basics: Drawing Images

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...

PyGame Basics: Game Loop

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...

PyGame Basics: Game Window

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 Basics: How to Setup PyGame

PyGame Basics: How to Setup PyGame

Before we jump into building a game, we will need to setup PyGame. Since PyGame requires Python, we will need to ensure it's installed first. This tutorial series assumes you will be using Python 3. You can download and install Python 3 from the official website....

PyGame Basics: Introduction

PyGame Basics: Introduction

We all know Python is highly flexible. What many don't know is that you can create awesome games with a library called, PyGame. PyGame is a cross-platform set of game development modules for Python. This series is meant to help you learn the basics of PyGame, and is...