Skip to main content

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: grafyte demo

License

Grafyte is licensed under the MIT License – see the LICENSE file for details.

Metadata

Release files for grafyte 0.3.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for grafyte 0.3.3
File Interpreter ABI Platform
grafyte-0.3.3-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
grafyte-0.3.3-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details

Total release size: 13.5 MB

Release files / grafyte-0.3.3-py3-none-win_amd64.whl

Download URL grafyte-0.3.3-py3-none-win_amd64.whl
Size 5.7 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
60d3fcbe3e3df1d99fdb258330bd38de8a4179eb09c69892ec4329cb817ff52e
BLAKE2b-256 checksum
How to use checksums
ed280cfd9c26a27480d300fcbc279d93a64b949c36a124808e25ac252567e02e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release files / grafyte-0.3.3-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL grafyte-0.3.3-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 7.8 MB
Tags Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
46cb9ddcafbb82ed4d8b3944da3d22195bf861c06264fb52c1abcb9edd8d574d
BLAKE2b-256 checksum
How to use checksums
00b0f09e475f8dc3db3e448e8e2436c9c369c70ad5ff5234e4095a1493fba065
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release history Release notifications | RSS feed

This release

0.3.3 This release

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page