A GPU-accelerated 2D game engine for Python with camera, drawing and packaging helpers.
Project description
PyBitEngine ⚡
A GPU-accelerated 2D game engine for Python, built on SDL2, ModernGL, NumPy and Numba.
PyBitEngine helps developers draw thousands of 2D objects efficiently while keeping the API simple. It uses instanced GPU rendering, texture atlases, and Numba kernels to reduce runtime overhead.
📦 Version: 0.1.1
This release expands the primitive set with rounded shapes and their fully-instanced batch counterparts, keeping the same SDF + AA pipeline used by every other primitive in the engine.
What is new in 0.1.1
- New immediate primitives:
DrawRoundedRect,DrawRoundedRectOutline,DrawRoundedTriangle,DrawRoundedTriangleOutline. - New GPU-instanced batch primitives:
DrawRoundedRectsBatch,DrawRoundedRectsOutlineBatch,DrawRoundedTrianglesBatch,DrawRoundedTrianglesOutlineBatch. - Rounded shapes share the same SDF fragment shader and
fwidth-based anti-aliasing used by rectangles, triangles and ellipses, so outlines stay visually consistent across every primitive (identical to the straight-edge version whenradius = 0). - Numba-parallel instance packing for both rounded rects and rounded triangles: one draw call per chunk, ~0 CPU overhead per shape.
radius,rotationandthicknessaccept either a scalar or a per-instance array of lengthnin every rounded batch call.- Documentation site updated to v0.1.1 with full coverage of the new shapes (signatures, parameters, examples).
✨ Highlights
- Instanced GPU rendering for rectangles, rounded rectangles, lines, triangles, rounded triangles, ellipses and sprites.
- Outline variants for every filled primitive, with a shared AA formula for consistent borders.
- Texture atlas packing with MaxRects allocation.
- 2D camera support with CPU and GPU-backed variants.
- Font rendering for TTF/OTF files with caching.
- SDL2 input handling for keyboard, mouse, drag and wheel events.
- Geometry helpers for points, rectangles, triangles, ellipses, circles and OBB collision checks.
🚀 Installation
pip install pybitengine
🧪 Quick usage
from PyBitEngine import WINDOW
window = WINDOW(title="PyBitEngine", geometry=("center", "center", 800, 600))
window.Loop()
🟦 Rounded shapes (new in 0.1.1)
# Immediate
draw.DrawRoundedRect(100, 100, 200, 80, radius=16, color=(255, 100, 50))
draw.DrawRoundedRectOutline(100, 100, 200, 80, radius=16, thickness=3,
color=(255, 255, 255))
draw.DrawRoundedTriangle(100, 50, 200, 200, 50, 200, radius=12,
color=(0, 255, 150))
# Batch (GPU-instanced, one draw call per chunk)
import numpy as np
pos = np.array([[10, 10], [120, 10], [230, 10]], dtype="f4")
size = np.array([[80, 40], [80, 40], [80, 40]], dtype="f4")
radius = np.array([6, 12, 20], dtype="f4") # per-instance radius
draw.DrawRoundedRectsBatch(pos, size, radius, colors=(255, 0, 128))
📦 Packaging a game
from PyBitEngine import pack
pack("main.py", name="MyGame", output_dir="dist")
📝 Notes
PyBitEngine is still evolving, but the core rendering and packaging APIs are increasingly stable and suitable for real projects. The 0.1.1 release rounds out (pun intended) the primitive set so UI panels, buttons and stylized shapes can be drawn with the same batched performance as everything else.
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 pybitengine-0.1.1.tar.gz.
File metadata
- Download URL: pybitengine-0.1.1.tar.gz
- Upload date:
- Size: 79.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ccc95d168014b7042b58c70b4fe2f06e00fc93bbea2e0329d402ef9149abdd05
|
|
| MD5 |
f7e4641fbdb6d46f6232bf5d36a3a281
|
|
| BLAKE2b-256 |
39bdcd58adc5871587bc5f08c73ab55b2dc2c81f2c82bad32b79d26070c5023d
|
File details
Details for the file pybitengine-0.1.1-py3-none-any.whl.
File metadata
- Download URL: pybitengine-0.1.1-py3-none-any.whl
- Upload date:
- Size: 81.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf0a5372fc1f5fedf3066ecfbd2d4205548baed63c185ddf18764792a39a8c34
|
|
| MD5 |
494260816cb1dbd8e35329e9c35e04a1
|
|
| BLAKE2b-256 |
e95508e865c25fdd618216bf9c8f942e6068c21816dfdd931a04c2d466fd6e5a
|