We can develop games in Python using PyGame. PyGame is a Python module that is used to develop games. This module includes computer graphics and sound libraries used in video game development.
To develop game in Python, we need PyGame. Therefore, we need to install PyGame.
We should Python and pip preinstalled on our system before installing PyGame.
Open the terminal and type the following command to install PyGame.
py -m pip install -U pygame --user
The PyGame module needs to be imported in Python IDE before writing the program for the game. There is some common code that includes displaying the pygame window of the desired size and closing the window.
import pygame pygame.init() screen = pygame.display.set_mode((400,500)) d=True while d: for event in pygame.event.get(): if event.type == pygame.QUIT: d = False pygame.display.flip()
The output will be a Pygame window with a quit and minimize button on the top right as any normal window.