Pygame#Notable games using Pygame
{{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{{cite web|url=https://github.com/pygame/pygame/graphs/contributors|title=Contributors to Pygame|publisher=GitHub}}
| developer = Pygame Community
| released = {{Start date and age|2000|10|28|df=y}}{{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 }}{{cite web |url=https://pypi.python.org/pypi/Pygame/ |title=Downloads - Pygame - Python game development|website=Pypi.python.org}}
| discontinued =
| latest release version = 2.6.1
| latest release date = {{Start date and age|2024|09|30|df=y}}{{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}}
| programming language = Python, C, Cython, and Assembly{{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}}{{cite web|url=https://www.pygame.org/wiki/GettingStarted|title=GettingStarted|website=Pygame.org}}
| operating system = Cross-platform
| platform =
| size =
| language =
| language count =
| language footnote =
| genre = API
| license = GNU Lesser General Public License
| alexa =
}}
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.{{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}}
History
Pygame was originally written by Pete Shinners to replace PySDL after its development stalled.{{cite web |url=http://sourceforge.net/projects/pysdl/ |title=pySDL sourceforge page|website=Sourceforge.net}} It has been a community project since 2000{{cite web|url=https://github.com/pygame/pygame/commit/a4e0f865c591980e7aa2a160a92a2c9098a678ec | title=commit by other authors|publisher=GitHub}} and is released under the free software GNU Lesser General Public License (which "provides for Pygame to be distributed with open source and commercial software"{{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}}).
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.{{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}}
Pygame 2.0 released on 28 October 2020, Pygame's 20th anniversary.{{cite web|url=https://github.com/pygame/pygame/releases/tag/2.0.0|title=pygame 2.0 - the happy dance birthday release|publisher=GitHub}}
Features
Pygame uses the Simple DirectMedia Layer (SDL) library,{{Efn|name=fn1}} 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.
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.{{cite web|url=https://www.pygame.org/docs/ |title=Pygame docs|website=Pygame.org}}
Applications using Pygame can run on Android phones and tablets with the use of Pygame Subset for Android (pgs4a).{{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}} Sound, vibration, keyboard, and accelerometer are supported on Android.{{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 }}
Community
{{Anchor|pygame-ce}}
Following disagreements between former core developers and the repository owner, a fork known as pygame-ce (Community Edition) was created.{{cite web|url=https://pypi.org/project/pygame-ce/|title=pygame - Community Edition |website=pypi.com}}
{{Anchor|PyWeek}}
There is a regular competition, called PyWeek, to write games using Python (and usually but not necessarily, Pygame).{{cite web|url=http://www.pyweek.org/|title=PyWeek - Python Game Programming Challenge|website=Pyweek.org}}{{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}}{{cite web|url=https://wiki.python.org/moin/PyWeek|title=PyWeek - Python Wiki|website=Wiki.python.org|access-date=1 April 2019}} The community has created many tutorials for Pygame.{{cite web|url=http://www.pygame.org/docs/|title=pygame documentation: Tutorials|website=Pygame.org}}{{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}}{{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}}{{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}}{{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}}
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
- Frets on Fire{{Cite web |title=fretsonfire/src at master · skyostil/fretsonfire |url=https://github.com/skyostil/fretsonfire |access-date=2023-06-02 |website=GitHub |language=en}}
- Dangerous High School Girls in Trouble!{{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}}
See also
Notes
{{Notelist|refs=
{{Efn|name=fn1|Pygame 2 and later versions are based on SDL2, while earlier releases were based on SDL1.{{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}}}}
}}
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:Python (programming language) libraries
Category:Simple DirectMedia Layer
Category:Video game development software