How to Install Pygame in Linux & Windows

In this article we want to learn How to Install Pygame in Linux & Windows.

 

What is Pygame ?

Pygame is free and open source library for creating games and multimedia applications using Python programming language. it provides functionalities for creating games 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 various game related tasks like collisions, game logic and game physics.

Pygame is designed to be simple and easy to use and it is great choice for beginners who want to create 2D games without having to learn complex game development concepts. 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 & Windows ?

Installing Pygame in Linux:

  1. Open terminal.
  2. Type following command to install the Pygame library:

  1. Wait for the installation process to complete.
  2. And also you can verify the installation by below command.

 

 

Installing Pygame in Windows:

  1. Download latest version of Pygame from their official website (https://www.pygame.org/download.shtml).
  2. Open command prompt.
  3. Type following command to install Pygame:

  1. Replace “pygame-1.9.6-cp38-cp38-win_amd64.whl” with the name of the Pygame wheel file you downloaded.
  2. Wait for the installation process to complete.
  3. And also you can verify the installation by below command.

 

Also you can install Pygame in Windows with pip command like this:

 

 

This is simple example of how to create a window using Pygame:

This code creates window with size of 400 x 300 pixels. the game loop checks for the QUIT event, which is generated when the user closes 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

 

 

Learn More on Python

 

Leave a Comment