Luma

A lightweight python game engine powered by SDL3


Project maintained by ItzCyzmiX Hosted on GitHub Pages — Theme by mattgraham

Getting Started

Requirements

Install the package from PyPI:

python -m pip install luma-engine

First window

Create main.py:

from luma import Luma


engine = Luma()
engine.create_window("My Luma Game", 640, 480)
graphics = engine.Graphics


@engine.draw
def draw():
    graphics.setDrawColor(40, 120, 220)
    graphics.drawRect(220, 160, 200, 120)
    graphics.resetDrawColor()


@engine.update
def update(dt):
    # Put movement and other game-state changes here.
    pass


engine.run()

Run it with:

python main.py

The window is cleared before every call to draw, so redraw the complete visible scene each frame. dt is the elapsed time since the previous frame in seconds; multiply speeds by it to make movement independent of frame rate.

Adding input

Register an event callback with engine.on:

@engine.on(Luma.EVENTS.KEYPRESS)
def on_key_press(key):
    if key == engine.Keyboard.KEYS.SPACE:
        print("Space pressed")

See Input for key-held movement and the full event behavior.