A shorthand wrapper for pygame that makes game development fast and easy
Project description
GLPG — GameLib for Pygame
A tiny wrapper for pygame that makes game development fast and approachable. Write games in a few lines instead of dozens.
pip install glpg
If you need a newer Python version, pygame-ce is also supported:
pip install pygame-ce glpg
Quickstart — Managed Loop
import glpg as gl
gl.window("720p", title="My Game", fps=60, bg_color="#1a1a2e")
@gl.on_update
def update(dt):
if gl.key("escape"):
gl.quit()
@gl.on_draw
def draw():
gl.draw.rect(100, 100, 64, 64, "#e63946")
gl.draw.circle(400, 300, 40, "cyan")
gl.draw.text("Hello GLPG", 20, 20, size=32, color="white")
gl.run()
Quickstart — Manual Loop
import glpg as gl
gl.window("720p", title="Manual Loop")
x = 100
while (dt := gl.tick()) is not None:
if gl.key("escape"):
gl.quit()
if gl.key("right"):
x += 200 * dt
gl.draw.rect(x, 300, 48, 48, "white")
gl.flip()
API Reference
Window
| Call | Description |
|---|---|
gl.window(size, title, icon, fps, bg_color) |
Initialise the window. Call once before anything else. |
gl.get_size() |
Returns (width, height) |
gl.get_width() / gl.get_height() |
Individual dimensions |
gl.set_title(title) |
Change the window title |
gl.set_fps(fps) |
Update the FPS cap at runtime |
gl.set_bg_color(color) |
Update the clear colour |
gl.get_screen() |
Raw pygame.Surface for advanced use |
Size strings: "480p" (854×480) · "720p" (1280×720) · "1080p" (1920×1080) · "1440p" (2560×1440)
Or pass a custom (width, height) tuple.
Managed Loop
| Call | Description |
|---|---|
@gl.on_update |
Decorator that runs each frame and receives dt (seconds) |
@gl.on_draw |
Decorator that runs each frame after clearing the screen |
gl.run() |
Start the managed loop and block until the window closes |
gl.quit() |
Signal the loop to stop |
gl.is_running() |
True while the loop is active |
gl.get_fps() |
Measured FPS for the current frame |
Manual Loop
| Call | Description |
|---|---|
gl.tick() |
Begin a frame, returns dt in seconds or None when finished |
gl.flip() |
Present the frame at the end of your loop |
gl.quit() |
Stop the loop on the next tick |
Drawing
All draw calls go through gl.draw.*.
| Call | Description |
|---|---|
gl.draw.rect(x, y, w, h, color, border, radius) |
Rectangle. Use radius for rounded corners. |
gl.draw.circle(x, y, radius, color, border) |
Circle centred at (x, y) |
gl.draw.ellipse(x, y, w, h, color, border) |
Ellipse inside a bounding box |
gl.draw.line(x1, y1, x2, y2, color, width) |
Line between two points |
gl.draw.polygon(points, color, border) |
Polygon from a list of (x, y) points |
gl.draw.text(content, x, y, size, color, font, center, antialias) |
Text. center=True centres on (x, y). Returns pygame.Rect |
gl.draw.image(path, x, y, scale, center, cache) |
Image from file. Returns pygame.Rect |
gl.draw.clear(color) |
Clear the screen. Defaults to window bg_color |
gl.draw.clear_image_cache() |
Evict cached image surfaces between scenes |
Colors accept:
- Named strings:
"red","white","cornflowerblue" - Hex strings:
"#e63946","#ff0000ff"(with alpha) - RGB tuples:
(255, 99, 71),(255, 99, 71, 128)
border=0 means filled. Any positive value draws an outline.
Input — Keyboard
| Call | Description |
|---|---|
gl.key("W") |
True while the key is held |
gl.key_pressed("space") |
True only on the first frame the key is pressed |
gl.key_released("shift") |
True only on the release frame |
Key names: letters a–z, digits 0–9, "space", "enter", "escape", "backspace", "tab", "up", "down", "left", "right", "shift", "ctrl", "alt" (also "lshift", "rshift" etc.), "f1"–"f12", "delete", "insert", "home", "end", "pageup", "pagedown".
Input — Mouse
| Call | Description |
|---|---|
gl.mouse.pos |
(x, y) cursor position |
gl.mouse.x / gl.mouse.y |
Individual coordinates |
gl.mouse.clicked("left") |
True only on the click frame. Buttons: "left", "right", "middle" |
gl.mouse.held("right") |
True while the button is held |
License
MIT License 2026
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file glpg_pygame-1.0.0.tar.gz.
File metadata
- Download URL: glpg_pygame-1.0.0.tar.gz
- Upload date:
- Size: 12.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2af3d7bb0b5183d37c8b45b7d0c7998d0017521a8257503fd9eacba3b4553cd3
|
|
| MD5 |
81c6fe7f1bbd939142b909bcd65e1e46
|
|
| BLAKE2b-256 |
7cfa0bb49b6f38cab6b3f7448e460abf9556280a79344e0296a82b8d63064b8a
|
File details
Details for the file glpg_pygame-1.0.0-py3-none-any.whl.
File metadata
- Download URL: glpg_pygame-1.0.0-py3-none-any.whl
- Upload date:
- Size: 12.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1c00d4c774eba09498544663123197c329b986696421e66dbc6535b12b9a049a
|
|
| MD5 |
94a8f067eedfce8303c80be386549cc8
|
|
| BLAKE2b-256 |
f4349404218b925e6b32faceecc085248c89aeb5bcc98243cd00e7564f40c05c
|