11. Exploring Pygame tool.

 

 11. Exploring Pygame tool.

Pygame

  • Pygame is a cross-platform set of Python modules which is used to create video games.
  • It consists of computer graphics and sound libraries designed to be used with the Python programming language.
  • Pygame was officially written by Pete Shinners to replace PySDL.
  • Pygame is suitable to create client-side applications that can be potentially wrapped in a standalone executable.

Pygame Installation

Install pygame in Windows

Before installing Pygame, Python should be installed in the system, and it is good to have 3.6.1 or above version because it is much friendlier to beginners, and additionally runs faster. There are mainly two ways to install Pygame, which are given below:

1. Installing through pip: The good way to install Pygame is with the pip tool (which is what python uses to install packages). The command is the following:

1.      py -m pip install -U pygame --user  

2. Installing through an IDE: The second way is to install it through an IDE and here we are using Pycharm IDE. Installation of pygame in the pycharm is straightforward. We can install it by running the above command in the terminal or use the following steps:

  • Open the File tab and click on the Settings option.
  • import pygame  

Simple pygame Example

 

import pygame  

  

pygame.init()  

screen = pygame.display.set_mode((400,500))  

done = False  

  

while not done:  

    for event in pygame.event.get():  

        if event.type == pygame.QUIT:  

            done = True  

    pygame.display.flip() 

Comments

Popular posts from this blog

1. Identification and solving of simple real life or scientific or technical problems, and developing flow charts for the same.

G3151-Problem Solving and Python Programming (2021 Regulations Anna University,Chennai)

12. Developing a game activity using Pygame like bouncing ball, car race etc.