Menu
Home Explore People Places Arts History Plants & Animals Science Life & Culture Technology
On this page
Pygame
Python module

Pygame is a cross-platform set of Python modules designed for writing video games. It includes computer graphics and sound libraries designed to be used with the Python programming language.

We don't have any images related to Pygame yet.
We don't have any YouTube videos related to Pygame yet.
We don't have any PDF documents related to Pygame yet.
We don't have any Books related to Pygame yet.
We don't have any archived web articles related to Pygame yet.

History

Pygame was originally written by Pete Shinners to replace PySDL after its development stalled.23 It has been a community project since 20004 and is released under the free software GNU Lesser General Public License5 (which "provides for Pygame to be distributed with open source and commercial software"6).

Development of version 2

Pygame version 2 was planned as "Pygame Reloaded" in 2009, but development and maintenance of Pygame completely stopped until the end of 2016 with version 1.9.1. After the release of version 1.9.5 in March 2019, development of a new version 2 was active on the roadmap.7

Pygame 2.0 released on 28 October 2020, Pygame's 20th anniversary.8

Features

Pygame uses the Simple DirectMedia Layer (SDL) library,9 with the intention of allowing real-time computer game development without the low-level mechanics of the C programming language and its derivatives. This is based on the assumption that the most expensive functions inside games can be abstracted from the game logic, making it possible to use a high-level programming language, such as Python, to structure the game.10

Other features that SDL does have include vector math, collision detection, 2D sprite scene graph management, MIDI support, camera, pixel-array manipulation, transformations, filtering, advanced freetype font support, and drawing.11

Applications using Pygame can run on Android phones and tablets with the use of Pygame Subset for Android (pgs4a).12 Sound, vibration, keyboard, and accelerometer are supported on Android.13

Community

Following disagreements between former core developers and the repository owner, a fork known as pygame-ce (Community Edition) was created.14

There is a regular competition, called PyWeek, to write games using Python (and usually but not necessarily, Pygame).151617 The community has created many tutorials for Pygame.1819202122

Sample code

The following code makes an image of a raccoon("raccoon.png") bounce when hitting an edge.

import pygame, sys pygame.init() screen = pygame.display.set_mode((1280, 720)) clock = pygame.time.Clock() clock.tick(30) black = 0, 0, 0 raccoon = pygame.image.load("raccoon.png") raccoon = pygame.transform.scale(raccoon, (200, 140)) raccoonrect = raccoon.get_rect() velocity = [1,1] while True: raccoonrect = raccoonrect.move(velocity) if raccoonrect.left < 0 or raccoonrect.right > 1280: velocity[0] = -velocity[0] raccoon = pygame.transform.flip(raccoon,True,False) if raccoonrect.top < 0 or raccoonrect.bottom > 720: velocity[1] = -velocity[1] for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() #screen update screen.fill(black) screen.blit(raccoon, raccoonrect) pygame.display.flip()

Notable games using Pygame

See also

  • Free and open-source software portal
  • Video games portal

Notes

References

  1. Alam, Imran (2 July 2023). "How to Implement a Dialogue System in Pygame". MUO. Retrieved 29 November 2024. https://www.makeuseof.com/implement-dialogue-system-in-pygame/

  2. Shinners, Pete. "Python Pygame Introduction - History". Pygame.org. Archived from the original on 17 September 2019. Retrieved 28 April 2017. https://web.archive.org/web/20190917011758/http://www.pygame.org/docs/tut/PygameIntro.html

  3. "pySDL sourceforge page". Sourceforge.net. http://sourceforge.net/projects/pysdl/

  4. "commit by other authors". GitHub. https://github.com/pygame/pygame/commit/a4e0f865c591980e7aa2a160a92a2c9098a678ec

  5. "About Pygame". GitHub. Archived from the original on 18 September 2019. Retrieved 31 August 2019. https://web.archive.org/web/20190918143814/http://www.pygame.org/wiki/about

  6. "Pygame Front Page — pygame v2.0.1.dev1 documentation". www.pygame.org. Retrieved 26 February 2021. https://www.pygame.org/docs/

  7. "pygame 1.9.5 released into the wilds". www.pygame.org. https://www.pygame.org/news/2019/3/1-9-5-released-into-the-wilds

  8. "pygame 2.0 - the happy dance birthday release". GitHub. https://github.com/pygame/pygame/releases/tag/2.0.0

  9. Pygame 2 and later versions are based on SDL2, while earlier releases were based on SDL1.[27]

  10. "About Pygame". GitHub. Archived from the original on 18 September 2019. Retrieved 31 August 2019. https://web.archive.org/web/20190918143814/http://www.pygame.org/wiki/about

  11. "Pygame docs". Pygame.org. https://www.pygame.org/docs/

  12. "Example of using RAPT to package pygame(_sdl2) games.: renpytom/rapt-pygame-example". GitHub. 1 April 2019. Retrieved 1 April 2019. https://github.com/renpytom/rapt-pygame-example

  13. "API — Pygame Subset for Android". Archived from the original on 19 October 2014. Retrieved 14 October 2014. https://web.archive.org/web/20141019204533/http://pygame.renpy.org/api.html

  14. "pygame - Community Edition". pypi.com. https://pypi.org/project/pygame-ce/

  15. "PyWeek - Python Game Programming Challenge". Pyweek.org. http://www.pyweek.org/

  16. Gee, Sue (29 March 2013). "Why PyWeek: An Interview with Richard Jones". i-programmer.info. Retrieved 31 March 2020. https://www.i-programmer.info/professional-programmer/i-programmer/5697-why-pyweek-an-interview-with-richard-jones-.html

  17. "PyWeek - Python Wiki". Wiki.python.org. Retrieved 1 April 2019. https://wiki.python.org/moin/PyWeek

  18. "pygame documentation: Tutorials". Pygame.org. http://www.pygame.org/docs/

  19. Siddiqi (27 June 2020). "Python Game projects with source code". CodersLegacy. Retrieved 25 December 2020. https://coderslegacy.com/python-game-projects-with-source-code/

  20. Shinners, Pete. "Line by line tutorial - Tutorial for beginners". Archived from the original on 5 February 2005. https://web.archive.org/web/20050205015600/http://www.pygame.org/docs/tut/chimp/ChimpLineByLine.html

  21. "Creating Games with Python - A tutorial explaining how to use pygame for game development and improved execution". Linuxjournal.com. http://www.linuxjournal.com/article/7694

  22. "Arinoid tutorials video tutorials at ShowMeDo". Archived from the original on 29 April 2007. https://web.archive.org/web/20070429111639/http://showmedo.com/videos/series?name=pythonArellanoPyGameSeries

  23. "fretsonfire/src at master · skyostil/fretsonfire". GitHub. Retrieved 2 June 2023. https://github.com/skyostil/fretsonfire

  24. "Dangerous High School Girls in Trouble!". Pygame.org. Retrieved 8 July 2011. http://pygame.org/project-Dangerous+High+School+Girls+in+Trouble!-791-.html