How to Install Pygame in Linux & Windows

In this article we want to learn How to Install Pygame in Linux & Windows, first of all let’s talk about Pygame.

 

 

What is Pygame ?

Pygame is free and open source library for creating games and multimedia applications using Python programming language. Using Pygame you can create different games functionalities  such as creating and handling images, animations, sound effects and musics. it also provides an event based framework for input handling (keyboard, mouse and joystick events) and support for different game related tasks like collisions, game logic and game physics.

Pygame is one of the best choice for beginners who want to create 2D games, because it id easy and simple. with Pygame you can create different types of games, from simple arcade games to more advanced games with nice graphics and sound effects.

 

 

How to Install Pygame in Linux?

Open terminal, and type following command to install the Pygame library:

 

 

How to Install Pygame in Windows?

You can install Pygame in Window using pip command, open your terminal or command prompt and write this command.

 

 

 

Now let’s create a simple example on Pygame, this is simple example of how to create a window using Pygame:

This code creates a window with size of 400 x 300 pixels. the game loop checks for the QUIT event, and it is waiting for the user to close the window, and sets the runing flag to False to exit the loop and quit the game. update function is called to update the screen with any changes made in the game loop.

 

 

 

 

Run the code and this will be the result

How to Install Pygame in Linux & Windows
How to Install Pygame in Linux & Windows

 

 

FAQs:

 

Is pygame already in Python?

No, Pygame is not included with Python by default. Pygame is a separate library that provides functionality for creating games and multimedia applications in Python. if you want to use Pygame and you want to create games in Python, then you need to install Pygame and you can use pip for the that.

 

 

What popular games use pygame?

Pygame has been used to create different popular games across different genres. Some well-known games developed with Pygame are:

  1. A Virus Named TOM: A puzzle game where players control a virus named Tom trying to infect a computer system.
  2. Darwinia: A real-time strategy game that combines elements of strategy, action and puzzles.
  3. flOw: An experimental game where players control an aquatic microorganism navigating through different stages of evolution.
  4. Frets on Fire: A music game inspired by Guitar Hero, where players use their keyboard to play along with songs.

 

These are just a few games, there are different projects that they are using Pygame library.

Subscribe and Get Free Video Courses & Articles in your Email

 

Leave a Comment

Share via
Copy link
Powered by Social Snap
×