{"schemaVersion":"1.0","record":{"label":"pygame","description":"Python multimedia library for code-driven games using SDL-based graphics, input and audio.","aliases":[],"kind":"software","website":"https://www.pygame.org/","overview":"pygame is a Python library for games and multimedia applications built on SDL and related libraries. It provides image surfaces, drawing, input events, sound and optional sprite-management helpers while leaving the main loop under application control. This article covers the upstream pygame distribution, distinct from the separately maintained pygame-ce fork.","license":"LGPL-2.1 for pygame; dependency licenses are separate and bundled example programs are public domain.","lifecycle":"active","example":false,"features":[{"name":"Surface-based 2D graphics","status":"supported","detail":"Surfaces represent images and support blitting, clipping, transparency and pixel manipulation.","useCase":"Building code-driven 2D games and multimedia applications in Python","platforms":["Windows","macOS","Linux"],"region":"Version, build and integration requirements apply","evidence":[{"url":"https://www.pygame.org/docs/ref/surface.html","locator":"Images, blitting, clipping, pixel access and shared subsurfaces","retrievedAt":"2026-10-07T19:59:56Z","kind":"vendor"}]},{"name":"Application-controlled loop","status":"supported","detail":"The application explicitly processes events, updates behavior, draws and presents frames.","useCase":"Building code-driven 2D games and multimedia applications in Python","platforms":["Windows","macOS","Linux"],"region":"Version, build and integration requirements apply","evidence":[{"url":"https://www.pygame.org/docs/","locator":"Application-controlled game loop and module overview","retrievedAt":"2026-10-07T19:53:52Z","kind":"vendor"},{"url":"https://www.pygame.org/docs/ref/event.html","locator":"Queue capacity, per-frame handling and display-thread restrictions","retrievedAt":"2026-10-07T20:00:09Z","kind":"vendor"}]},{"name":"Sprite grouping and collision queries","status":"supported","detail":"Optional Sprite and Group classes provide organization and rectangle, circle or mask collision helpers.","useCase":"Building code-driven 2D games and multimedia applications in Python","platforms":["Windows","macOS","Linux"],"region":"Version, build and integration requirements apply","evidence":[{"url":"https://www.pygame.org/docs/ref/sprite.html","locator":"Optional Sprite/Group classes and collision helpers","retrievedAt":"2026-10-07T20:01:02Z","kind":"vendor"}]},{"name":"Sound effects and music","status":"limited","detail":"The optional SDL_mixer-backed module requires initialization and available dependencies; music has a separate streaming path.","useCase":"Building code-driven 2D games and multimedia applications in Python","platforms":["Windows","macOS","Linux"],"region":"Version, build and integration requirements apply","evidence":[{"url":"https://www.pygame.org/docs/ref/mixer.html","locator":"Optional mixer, channels, background playback and streaming music","retrievedAt":"2026-10-07T20:01:02Z","kind":"vendor"}]}],"alternatives":[],"slug":"pygame","draftAlternatives":[{"targetSlug":"pygame-ce","status":"limited","detail":"Assessment: an alternative for Python 2D projects that only need the shared pygame-style APIs. CE-specific additions are not established as available upstream, and the two distributions must not be treated as independent co-installable providers of different import namespaces.","useCase":"Building code-driven 2D games and multimedia applications in Python","platforms":["Windows","macOS","Linux"],"region":"Version, build and integration requirements apply","evidence":[{"url":"https://www.pygame.org/docs/","locator":"Application-controlled game loop and module overview","retrievedAt":"2026-10-07T19:53:52Z","kind":"vendor"},{"url":"https://github.com/pygame-community/pygame-ce/blob/main/README.rst","locator":"Separate fork and Python multimedia scope","retrievedAt":"2026-10-07T20:00:21Z","kind":"vendor"},{"url":"https://github.com/pygame-community/pygame-ce/wiki/Installing-pygame%E2%80%90ce","locator":"Conflicting package installation and isolated environments","retrievedAt":"2026-10-07T20:00:50Z","kind":"vendor"}]}],"evidence":[{"url":"https://github.com/pygame/pygame/blob/main/README.rst","locator":"Scope, installation, documentation versions, dependencies and licensing","retrievedAt":"2026-10-07T20:00:21Z","kind":"vendor"},{"url":"https://www.pygame.org/docs/","locator":"Application-controlled game loop and module overview","retrievedAt":"2026-10-07T19:53:52Z","kind":"vendor"},{"url":"https://www.pygame.org/docs/ref/surface.html","locator":"Images, blitting, clipping, pixel access and shared subsurfaces","retrievedAt":"2026-10-07T19:59:56Z","kind":"vendor"},{"url":"https://www.pygame.org/docs/ref/event.html","locator":"Queue capacity, per-frame handling and display-thread restrictions","retrievedAt":"2026-10-07T20:00:09Z","kind":"vendor"},{"url":"https://www.pygame.org/docs/ref/sprite.html","locator":"Optional Sprite/Group classes and collision helpers","retrievedAt":"2026-10-07T20:01:02Z","kind":"vendor"},{"url":"https://www.pygame.org/docs/ref/mixer.html","locator":"Optional mixer, channels, background playback and streaming music","retrievedAt":"2026-10-07T20:01:02Z","kind":"vendor"},{"url":"https://github.com/pygame-community/pygame-ce/blob/main/README.rst","locator":"Separate fork and Python multimedia scope","retrievedAt":"2026-10-07T20:00:21Z","kind":"vendor"},{"url":"https://github.com/pygame-community/pygame-ce/wiki/Installing-pygame%E2%80%90ce","locator":"Conflicting package installation and isolated environments","retrievedAt":"2026-10-07T20:00:50Z","kind":"vendor"}],"document":{"version":1,"references":[{"url":"https://github.com/pygame/pygame/blob/main/README.rst","locator":"Scope, installation, documentation versions, dependencies and licensing","retrievedAt":"2026-10-07T20:00:21Z","id":"repo","title":"pygame README","kind":"vendor"},{"url":"https://www.pygame.org/docs/","locator":"Application-controlled game loop and module overview","retrievedAt":"2026-10-07T19:53:52Z","id":"quick","title":"pygame documentation","kind":"vendor"},{"url":"https://www.pygame.org/docs/ref/surface.html","locator":"Images, blitting, clipping, pixel access and shared subsurfaces","retrievedAt":"2026-10-07T19:59:56Z","id":"surface","title":"pygame Surface reference","kind":"vendor"},{"url":"https://www.pygame.org/docs/ref/event.html","locator":"Queue capacity, per-frame handling and display-thread restrictions","retrievedAt":"2026-10-07T20:00:09Z","id":"events","title":"pygame event reference","kind":"vendor"},{"url":"https://www.pygame.org/docs/ref/sprite.html","locator":"Optional Sprite/Group classes and collision helpers","retrievedAt":"2026-10-07T20:01:02Z","id":"sprites","title":"pygame sprite reference","kind":"vendor"},{"url":"https://www.pygame.org/docs/ref/mixer.html","locator":"Optional mixer, channels, background playback and streaming music","retrievedAt":"2026-10-07T20:01:02Z","id":"audio","title":"pygame mixer reference","kind":"vendor"},{"url":"https://github.com/pygame-community/pygame-ce/blob/main/README.rst","locator":"Separate fork and Python multimedia scope","retrievedAt":"2026-10-07T20:00:21Z","id":"ce","title":"pygame-ce README","kind":"vendor"},{"url":"https://github.com/pygame-community/pygame-ce/wiki/Installing-pygame%E2%80%90ce","locator":"Conflicting package installation and isolated environments","retrievedAt":"2026-10-07T20:00:50Z","id":"ce-install","title":"Installing pygame-ce","kind":"vendor"}],"overviewCitations":["repo","quick","ce"],"licenseCitations":["repo"],"sections":[{"id":"loop","heading":"Main loop and responsiveness","paragraphs":[{"id":"loop-detail","content":[{"text":"A pygame program normally initializes its modules, creates a display, processes events, updates application state and draws each frame. The event queue is bounded and can drop newly arriving events when full. Its documentation therefore makes regular event processing part of the application's responsibility, including when the program otherwise polls device state directly. Event operations also carry restrictions tied to the thread that initialized the display."}],"citations":["quick","events"]}]},{"id":"drawing","heading":"Images and drawing","paragraphs":[{"id":"drawing-detail","content":[{"text":"Surfaces represent images with a defined resolution and pixel format. Blitting copies image content onto another surface, with clipping and transparency controlling the result. A subsurface can share its parent's pixels, so modifying either can affect the same underlying image. For substantial pixel work, the documentation points to PixelArray or NumPy-backed surfarray operations instead of repeated individual pixel calls."}],"citations":["surface"]}]},{"id":"objects","heading":"Sprites and game objects","paragraphs":[{"id":"objects-detail","content":[{"text":"Sprite and Group classes are optional conveniences rather than a mandatory engine architecture. Developers supply image and rectangle attributes for basic group drawing and can use different groups for rendering and interaction. Collision helpers cover shapes such as rectangles, circles and masks. The module warns that sprites are not thread-safe, so introducing worker threads does not automatically make shared object manipulation safe."}],"citations":["sprites"]}]},{"id":"sound","heading":"Audio behavior","paragraphs":[{"id":"sound-detail","content":[{"text":"The mixer loads Sound objects and plays them through a configurable pool of channels, with mixing occurring in background threads. A separate music interface streams long-running tracks instead of loading an entire sound into memory. Mixer availability depends on its SDL_mixer dependency and successful initialization. Buffer configuration can trade latency against dropout risk, so audio behavior should be evaluated with the actual distribution and hardware."}],"citations":["audio"]}]},{"id":"environment","heading":"Environment and documentation","paragraphs":[{"id":"environment-detail","content":[{"text":"The upstream package is distributed as pygame and depends on Python, SDL and several media-related libraries. The README warns that online documentation follows development and may describe features newer than an installed release. A project's supported Python version, packaged native dependencies and feature expectations should consequently be evaluated together, rather than inferred from a documentation page's availability alone."}],"citations":["repo"]}]},{"id":"licensing","heading":"Licensing","paragraphs":[{"id":"licensing-detail","content":[{"text":"The README identifies LGPL version 2.1 as pygame's license and explicitly permits commercial and closed-source games. Modifications to the library itself and redistribution obligations remain separate from the license chosen for game code. It also identifies bundled example programs as public domain and directs developers to the dependency notices for other incorporated components."}],"citations":["repo"]}]},{"id":"comparison","heading":"Relationship to Community Edition","paragraphs":[{"id":"comparison-detail","content":[{"text":"pygame and "},{"text":"pygame-ce","targetSlug":"pygame-ce"},{"text":" offer overlapping Python game-development APIs, but they are distinct distributions. CE's installation guide warns against keeping both installed together because of package conflicts. Choosing upstream pygame can cover projects that stay within the shared API, but CE-only functions need separate review before switching back. Neither the common import name nor project ancestry establishes identical behavior for every game."}],"citations":["ce","ce-install","quick"]}]}]},"id":"Q576","revision":624,"updatedAt":"2026-10-12T23:11:45Z","sourceUrl":"https://substitutefor.net/entities/Q576?revision=624"}}