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.2
This is a stability and correctness release. It focuses on fixing rendering-order bugs, camera-shake artifacts, geometric collision edge cases and a few packaging rough edges reported against 0.1.1. No public API was removed or renamed: upgrading from 0.1.1 requires no code changes.
What is new in 0.1.2
- Painter's algorithm fixed for textures + primitives.
DrawTexturenow participates in the same_use_batchbatching used by every other primitive. MixingDrawTexture,DrawRect,DrawRoundedRect, etc. now produces draw calls in the exact order of theDraw*calls — no more textures rendered after rectangles regardless of call order. - Screen-shake bias removed on both
CameraGPUandCameraCPU. The shake offset is now a zero-mean oscillation (sin/cos * factor) instead of the previous2*sin - 1formula that produced a net drift toward the bottom-left. - Polygon vs Ellipse collision now also tests polygon edges against the ellipse boundary. Cases where an ellipse crosses a polygon edge without containing any vertex and without having its center inside are correctly reported as colliding (previously false negatives).
- PE_PAKER —
pack()injects the absolute directory of the source script intosys.pathof the generatedsetup.py, instead ofPath.cwd()at generation time. Packaging now works reliably whenpack()is invoked from a directory other than the project root. - Minor documentation and comment cleanups across
PE_DRAW,PE_CAMERAandPE_PAKERexplaining the invariants behind the fixes above.
✨ 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()
🎨 Correct layering (fixed in 0.1.2)
# Draw calls now render strictly in the order they are issued,
# even when mixing textures and primitives.
draw.DrawTexture("background", 0, 0, 800, 600) # layer 0
draw.DrawRect(100, 100, 50, 50, color=(255, 0, 0)) # layer 1 (above bg)
draw.DrawTexture("player", 200, 200, 32, 32) # layer 2 (above rect)
🟦 Rounded shapes (from 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.2 release is a maintenance drop on top of 0.1.1: same features, more correct behavior when mixing textures with primitives, using camera shake, or packaging from a non-standard working directory.
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.2.tar.gz.
File metadata
- Download URL: pybitengine-0.1.2.tar.gz
- Upload date:
- Size: 102.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dbb38d65ec7c6cb544feada8cb161ac394115f6f7415a56a72004165ac74351b
|
|
| MD5 |
ce44d4626edddd1448bec99c75b9ccbd
|
|
| BLAKE2b-256 |
f343e37e42505e543033d0d53dfc8ec07308049fcc23676370e7e7fa18959984
|
File details
Details for the file pybitengine-0.1.2-py3-none-any.whl.
File metadata
- Download URL: pybitengine-0.1.2-py3-none-any.whl
- Upload date:
- Size: 104.3 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 |
ff87baa71d784000e3f9d99f3bd6959f1728d6f226e825d3ddd640efe2189627
|
|
| MD5 |
c9d9937f0f33e6efff403fd003f0ccba
|
|
| BLAKE2b-256 |
9863e700fa2d127e7aab9300b8d2a04c29e1957d7c5948d206db35c00cdd817a
|