Pygame Community Edition

2.5.7 · active · verified Thu Apr 16

Pygame-ce (Pygame Community Edition) is an actively maintained, free and open-source Python library for multimedia applications and game development. It is a community-driven fork of the original Pygame, built on top of the Simple DirectMedia Layer (SDL) library. It offers frequent updates, bug fixes, performance enhancements, and improved compatibility with newer Python versions and operating systems. The current stable version is 2.5.7.

Common errors

Warnings

Install

Imports

Quickstart

This basic example initializes Pygame-ce, creates a window, sets its title, and enters a game loop. Inside the loop, it handles the `QUIT` event to close the window, fills the screen with a blue color, draws a white circle, and updates the display. Finally, it properly shuts down Pygame.

import pygame
import sys

pygame.init()

SCREEN_WIDTH = 800
SCREEN_HEIGHT = 600
SCREEN_TITLE = 'Pygame-CE Quickstart'

screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
pygame.display.set_caption(SCREEN_TITLE)

WHITE = (255, 255, 255)
BLUE = (0, 0, 255)

running = True
while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

    screen.fill(BLUE) # Fill the screen with blue

    # Example: Draw a white circle
    pygame.draw.circle(screen, WHITE, (SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2), 50)

    pygame.display.flip() # Update the full display Surface to the screen

pygame.quit()
sys.exit()

view raw JSON →