Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Pygame
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Python module for writing video games}} {{Use dmy dates|date=September 2023}} {{Infobox software | title = | name = Pygame | logo = Pygame logo.svg | logo caption = | logo size = 250px | screenshot = | caption = | collapsible = | author = Lenard Lindstrom, RenΓ© Dudfield, Pete Shinners, Nicholas Dudfield, Thomas Kluyver, and others<ref>{{cite web|url=https://github.com/pygame/pygame/graphs/contributors|title=Contributors to Pygame|publisher=[[GitHub]]}}</ref> | developer = Pygame Community | released = {{Start date and age|2000|10|28|df=y}}<ref name="pygame-intro">{{cite web |url=http://www.pygame.org/docs/tut/PygameIntro.html |title=Python Pygame Introduction - History |last=Shinners |first=Pete |website=Pygame.org |access-date=2017-04-28 |archive-url=https://web.archive.org/web/20190917011758/http://www.pygame.org/docs/tut/PygameIntro.html |archive-date=2019-09-17 |url-status=dead }}</ref><ref>{{cite web |url=https://pypi.python.org/pypi/Pygame/ |title=Downloads - Pygame - Python game development|website=Pypi.python.org}}</ref> | discontinued = | latest release version = 2.6.1 | latest release date = {{Start date and age|2024|09|30|df=y}}<ref>{{cite web |url= https://github.com/pygame/pygame/releases/tag/2.6.1|access-date=2025-03-16 |title=PyGame 2.6.1 - Python 3.13 bugfix release}}</ref> | programming language = [[Python (programming language)|Python]], [[C (programming language)|C]], [[Cython]], and [[Assembly language|Assembly]]<ref name="about">{{cite web|url=https://www.pygame.org/wiki/about|title=About Pygame|publisher=GitHub|access-date=31 August 2019|archive-url=https://web.archive.org/web/20190918143814/http://www.pygame.org/wiki/about|archive-date=18 September 2019|url-status=dead}}</ref><ref>{{cite web|url=https://www.pygame.org/wiki/GettingStarted|title=GettingStarted|website=Pygame.org}}</ref> | operating system = [[Cross-platform]] | platform = | size = | language = | language count = <!-- DO NOT include this parameter unless you know what it does --> | language footnote = | genre = [[Application Programming Interface|API]] | license = [[GNU Lesser General Public License]] | alexa = }} '''Pygame''' is a [[cross-platform]] set of [[Python (programming language)|Python]] modules designed for writing [[video game]]s. It includes [[computer graphics]] and sound [[library (computing)|libraries]] designed to be used with the Python [[programming language]].<ref>{{Cite web |last=Alam |first=Imran |date=2023-07-02 |title=How to Implement a Dialogue System in Pygame |url=https://www.makeuseof.com/implement-dialogue-system-in-pygame/ |access-date=2024-11-29 |website=MUO |language=en}}</ref> ==History== Pygame was originally written by [[Pete Shinners]] to replace [[PySDL]] after its development stalled.<ref name="pygame-intro"/><ref>{{cite web |url=http://sourceforge.net/projects/pysdl/ |title=pySDL sourceforge page|website=Sourceforge.net}}</ref> It has been a [[free software community|community]] project since 2000<ref>{{cite web|url=https://github.com/pygame/pygame/commit/a4e0f865c591980e7aa2a160a92a2c9098a678ec | title=commit by other authors|publisher=GitHub}}</ref> and is released under the [[free software]] [[GNU Lesser General Public License]]<ref name="about"/> (which "provides for Pygame to be distributed with [[open-source software|open source]] and commercial software"<ref>{{Cite web|title=Pygame Front Page β pygame v2.0.1.dev1 documentation|url=https://www.pygame.org/docs/|access-date=2021-02-26|website=www.pygame.org}}</ref>). ==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.<ref>{{cite web|url= https://www.pygame.org/news/2019/3/1-9-5-released-into-the-wilds | title= pygame 1.9.5 released into the wilds |website= www.pygame.org}}</ref> Pygame 2.0 released on 28 October 2020, Pygame's 20th anniversary.<ref>{{cite web|url=https://github.com/pygame/pygame/releases/tag/2.0.0|title=pygame 2.0 - the happy dance birthday release|publisher=GitHub}}</ref> ==Features== Pygame uses the [[Simple DirectMedia Layer]] (SDL) library,{{Efn|name=fn1}} with the intention of allowing [[real-time computer graphics|real-time]] [[computer game]] development without the [[low-level programming language|low-level]] mechanics of the [[C (programming language)|C programming language]] and its derivatives. This is based on the assumption that the most [[computationally expensive|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.<ref name="about"/> 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.<ref>{{cite web|url=https://www.pygame.org/docs/ |title=Pygame docs|website=Pygame.org}}</ref> Applications using Pygame can run on Android phones and tablets with the use of Pygame Subset for Android (pgs4a).<ref>{{cite web|url=https://github.com/renpytom/rapt-pygame-example|title=Example of using RAPT to package pygame(_sdl2) games.: renpytom/rapt-pygame-example|date=1 April 2019|access-date=1 April 2019|publisher=GitHub}}</ref> Sound, vibration, keyboard, and accelerometer are supported on Android.<ref>{{cite web|url=http://pygame.renpy.org/api.html |title=API β Pygame Subset for Android |access-date=14 October 2014 |url-status=dead |archive-url=https://web.archive.org/web/20141019204533/http://pygame.renpy.org/api.html |archive-date=19 October 2014 }}</ref> ==Community== {{Anchor|pygame-ce}} Following disagreements between former core developers and the repository owner, a fork known as pygame-ce (Community Edition) was created.<ref>{{cite web|url=https://pypi.org/project/pygame-ce/|title=pygame - Community Edition |website=pypi.com}}</ref> {{Anchor|PyWeek}} There is a regular competition, called PyWeek, to write games using Python (and usually but not necessarily, Pygame).<ref>{{cite web|url=http://www.pyweek.org/|title=PyWeek - Python Game Programming Challenge|website=Pyweek.org}}</ref><ref>{{cite web|url=https://www.i-programmer.info/professional-programmer/i-programmer/5697-why-pyweek-an-interview-with-richard-jones-.html|title=Why PyWeek: An Interview with Richard Jones|last=Gee|first=Sue|website=i-programmer.info|date=29 March 2013|access-date=31 March 2020}}</ref><ref>{{cite web|url=https://wiki.python.org/moin/PyWeek|title=PyWeek - Python Wiki|website=Wiki.python.org|access-date=1 April 2019}}</ref> The community has created many tutorials for Pygame.<!-- First ref is a primary source, but still relevant. Other refs clearly support this assertion --><ref>{{cite web|url=http://www.pygame.org/docs/|title=pygame documentation: Tutorials|website=Pygame.org}}</ref><ref>{{Cite web|last=Siddiqi|date=2020-06-27|title=Python Game projects with source code|url=https://coderslegacy.com/python-game-projects-with-source-code/|access-date=2020-12-25|website=CodersLegacy|language=en-US}}</ref><ref>{{cite web|url=http://pygame.org/docs/tut/chimp/ChimpLineByLine.html|title=Line by line tutorial - Tutorial for beginners|last=Shinners|first=Pete|url-status=dead|archive-url=https://web.archive.org/web/20050205015600/http://www.pygame.org/docs/tut/chimp/ChimpLineByLine.html|archive-date=5 February 2005}}</ref><ref>{{cite web|url=http://www.linuxjournal.com/article/7694|title=Creating Games with Python - A tutorial explaining how to use pygame for game development and improved execution|website=Linuxjournal.com}}</ref><ref>{{cite web|url=http://showmedo.com/videos/series?name=pythonArellanoPyGameSeries|title=Arinoid tutorials video tutorials at ShowMeDo|url-status=dead|archive-url=https://web.archive.org/web/20070429111639/http://showmedo.com/videos/series?name=pythonArellanoPyGameSeries|archive-date=29 April 2007}}</ref> ==Sample code== The following code makes an image of a raccoon("raccoon.png") bounce when hitting an edge. <syntaxhighlight lang="python"> 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()</syntaxhighlight> ==Notable games using Pygame== * ''[[Frets on Fire]]''<ref>{{Cite web |title=fretsonfire/src at master Β· skyostil/fretsonfire |url=https://github.com/skyostil/fretsonfire |access-date=2023-06-02 |website=GitHub |language=en}}</ref> * ''[[Dangerous High School Girls in Trouble!]]''<ref>{{cite web|title=Dangerous High School Girls in Trouble!|url=http://pygame.org/project-Dangerous+High+School+Girls+in+Trouble!-791-.html|website=Pygame.org|access-date=8 July 2011}}</ref> ==See also== {{Portal|Free and open-source software|Video games}} * [[Cocos2d]] * [[Panda3D]] * [[Pyglet]] ==Notes== {{Notelist|refs= {{Efn|name=fn1|Pygame 2 and later versions are based on SDL2, while earlier releases were based on SDL1.<ref>{{cite web|url=https://www.pygame.org/news/2019/3/1-9-5-released-into-the-wilds|title=pygame 1.9.5 released into the wilds|website=Pygame.org}}</ref>}} }} ==References== {{Reflist|30em}} ==External links== * {{Official website}} * [news://gmane.comp.python.pygame Pygame newsgroup] [https://web.archive.org/web/20070129083639/http://news.gmane.org/gmane.comp.python.pygame (web access)] - the "official" * [http://pygame.renpy.org/ Pygame Subset for Android] (PGS4A) * [http://pyopengl.sourceforge.net/ pyOpenGL] - Python OpenGL Bindings * [https://pygame-sdl2.readthedocs.io/ Pygame-SDL2] - a reimplementation of Pygame APIs on top of SDL2 * [https://pysdl2.readthedocs.io/ PySDL2] - a wrapper around the SDL2 library similar to the discontinued PySDL project {{Video game engines}} [[Category:Application programming interfaces]] [[Category:Free computer libraries]] [[Category:Free software programmed in Python]] [[Category:Graphics libraries]] [[Category:Linux APIs]] [[Category:MacOS APIs]] [[Category:Python (programming language) libraries]] [[Category:Simple DirectMedia Layer]] [[Category:Video game development software]] [[Category:Video game development software for Linux]] [[Category:Windows APIs]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Anchor
(
edit
)
Template:Cite web
(
edit
)
Template:Efn
(
edit
)
Template:Infobox
(
edit
)
Template:Infobox software
(
edit
)
Template:Main other
(
edit
)
Template:Notelist
(
edit
)
Template:Official website
(
edit
)
Template:Portal
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)
Template:Template other
(
edit
)
Template:Use dmy dates
(
edit
)
Template:Video game engines
(
edit
)