How to Load image from Web URL in Pygame

Pygame is a popular library in Python for creating games and graphical applications. One of the essential tasks in creating games is loading images into the game window. Pygame provides several functions to load images from files, but what if you want to load an image from using a web image url? In this article, … Read more

How to get mouse position in Pygame?

In this Pygame tutorial, we will explore how we can return the current Mouse Position on our Game Window. Knowing the current position of the mouse is necessary to perform basic tasks, such as interaction with objects (through mouse cursor) or drag and drop features. How to get current Mouse Position? To get the mouse … Read more

Pygame – How to Draw Shapes (Rectangles, Circles…)

In this Pygame Tutorial we will be discussing how to use the “draw” module for drawing shapes to our Pygame Window. This module is essentially a collection of various drawing functions, each used to draw a unique shape or object. Drawing Functions in Pygame Here is a list of all the drawing functions available to … Read more

How to Rotate an Image in Pygame

Pygame allows us to load, create and render images to the screen. Naturally, when dealing with images we often wonder “How do we rotate an image in Pygame” before drawing it to the screen. Luckily Pygame provides built in functions for this purpose, so we do not have to rely on other libraries. Rotate Images … Read more

How to resize an image in Pygame?

In this Pygame tutorial we will explore how to “Resize” an Image in Pygame. There are several re-sizing and scaling functions in Pygame that we can use to resize images, each with it’s own unique twist. Let’s begin exploring the right away! Before we begin resizing an image however, we first need to load it … Read more

How to make a PyGame Window?

The very first step to creating your Pygame application is to make the Pygame Window. This is the window to which you will be drawing and rendering various shapes, sprites, text and other objects. Let’s explore how we can make this Window and use the various flags and settings related to it. Setting up Pygame … Read more

Text Input in Pygame

Taking input from the user through the console is a very easy task. But what about taking text input from the user through a GUI created in Pygame? This is a bit harder, because Pygame offers no built-in widget that does this for you. It does however have a bunch of others features that we … Read more

How to make a Text Input Box in Pygame

One of the major challenges you will face in Pygame is how to take input from the User. Normally in browsers or any other GUI application, you use a Text Input Box to take input. However, Pygame has no such built-in feature, so we need to make our own Text Input Box. Luckily we have … Read more

Download and Install Pygame in Python

In this tutorial we will show you how to download, install and setup the Pygame Library in Python. Installing Pygame in Python The most universal method of installing pygame is through the use of pip. It’s a package installer for Python commonly used for installing python libraries. It usually comes bundled with Python (atleast on … Read more

Pygame for Beginners (Tutorials Collection)

This article is a compilation of the various tutorials on Pygame available on CodersLegacy. We have tutorials on just about every Pygame topic and feature. For your convenience, we have sorted the pygame tutorials into subgroups and also listed which tutorials beginners should start with. More tutorials are constantly being added to the below list. … Read more

How to display FPS in Pygame (frames per second)

In this tutorial we will show you how to implement, retrieve and display the current FPS (frames per second) for your Pygame application. Role of FPS in Pygame By default your Pygame program has no “fixed fps”. What this means is that your program has no limit on the number of times it updates/renders it’s … Read more

Introduction to Pygame (for beginners)

This Python Tutorial is an introduction to the popular game library “Pygame”. Pygame is a game library used commonly to create 2-D games in Python. It comes with many important features such as Collision Detection, Sound and Music, Graphics, an Event System and much more. You can learn more about these amazing features by following … Read more