A simple rendering engine with some game engine features made with OpenGL for Python
Project description
Grafyte
Grafyte is a lightweight and simple 2D game engine written in C++ with OpenGL and exposed to Python using pybind11. It aims to provide a fast and easy-to-use interface for creating 2D games and interactive applications.
Features
- Simple API: Designed for ease of use with a straightforward Pythonic interface.
- Fast Rendering: Core engine written in C++ using OpenGL.
- 2D Sprites: Support for textures and colored objects.
- Text Rendering: Easy text display with scale and color control.
- Simple Collision System: Integrated AABB-based collision detection with automatic resolution.
- Input Management: Easy-to-use action-based input system with support for keyboard triggers (Press, Hold, Release).
- Scene-based Workflow: Manage game objects within scenes.
Installation
To install grafyte, run the following command in your terminal:
python -m pip install grafyte
Building from Source
Prerequisites
- Python 3.10+
- A C++ compiler (MSVC, GCC, or Clang)
- CMake
- OpenGL drivers
[!NOTE] When applicable, please make sure to test your code on both windows and linux as well as on Python 3.10 to 3.14 if possible.
Build
To set up the development environment and build Grafyte:
Windows:
scripts\setup.bat
.\.venv\Scripts\activate
pip install .
Linux:
chmod +x scripts/setup.sh
./scripts/setup.sh
source .venv/bin/activate
pip install .
Finally, you can build the python extension using CMake:
mkdir build
cd build
cmake ..
cmake --build .
Quick Start
Here's a minimal example to get you started:
import grafyte
from grafyte import Key, InputTrigger
# Initialize application
app = grafyte.Application("My Game", (800, 600))
scene = app.make_new_scene()
# Create a player object
player = scene.spawn_object((0, 0), (50, 50))
player.color = (0, 255, 0), 1.0
# Register an action
app.input.create_action("move_right", InputTrigger.Hold, Key.D)
while not app.should_close():
dt = app.dt
# Handle input
if app.input["move_right"]:
player.pos.x += 100 * dt
# Render scene
app.render()
app.quit()
For further information, please refer to the full documentation on readthedocs.io
Demo
Here is another example of a game made using only grafyte:
License
Grafyte is licensed under the MIT License – see the LICENSE file for details.
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 Distributions
Built Distributions
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 grafyte-0.3.2-py3-none-win_amd64.whl.
File metadata
- Download URL: grafyte-0.3.2-py3-none-win_amd64.whl
- Upload date:
- Size: 5.7 MB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aeebc1f4adaaa34bfec9e1410f9164fee29172735df2e01380e1e8aaec9a84f7
|
|
| MD5 |
4eb43275c229ab1ac15056dad4be05aa
|
|
| BLAKE2b-256 |
63c4e9273f382a9d0a58cb6c51ddf9ec17e8345d1946808c53239dd5dfa26d15
|
File details
Details for the file grafyte-0.3.2-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: grafyte-0.3.2-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 7.8 MB
- Tags: Python 3, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
30ab7d07a3c4d5405d6a101f1df7dfb968cef17204a07877b4e1694d1d8d3cf4
|
|
| MD5 |
bf25fb4f0c602fef9fe53fe3f1b044d2
|
|
| BLAKE2b-256 |
a1f0702357b75466d3c785e4fc28e24ce010cad84d311e5d9d611c3fc39b88b1
|