LuaGame
A pygame-powered engine that lets you make games in Lua!
Write your game in a .lua file, run it with one Python line.
Compatibility:
This package uses pygame to run properly. The python version this was made on is python 3.12, it might run in higher versions
Installation
pip install LuaGame
How to Use
1. Create your game file: mygame.lua
-- runs once at the start
function load()
player_x = 400
player_y = 300
end
-- runs every frame (dt = time since last frame in seconds)
function update(dt)
if is_key_down("left") then player_x = player_x - 200 * dt end
if is_key_down("right") then player_x = player_x + 200 * dt end
end
-- draw everything here
function draw()
clear(30, 30, 40)
draw_rect(player_x, player_y, 40, 40, 80, 140, 255)
draw_text("Use arrow keys!", 10, 10, 24, 255, 255, 255)
end
2. Run it with Python:
from LuaGame import run_game
run_game("mygame.lua", width=800, height=600, title="My Game")
That's it!
Lua Functions Reference
Drawing
| Function | What it does |
|---|---|
clear(r, g, b) |
Fill the screen with a color |
draw_rect(x, y, w, h, r, g, b) |
Draw a filled rectangle |
draw_circle(x, y, radius, r, g, b) |
Draw a filled circle |
draw_line(x1, y1, x2, y2, r, g, b, width) |
Draw a line |
draw_text(text, x, y, size, r, g, b) |
Draw text on screen |
draw_image(path, x, y) |
Draw an image file |
Input
| Function | What it does |
|---|---|
is_key_down("key") |
True if a key is held down (e.g. "left", "space", "a") |
get_mouse_pos() |
Returns x, y of the mouse |
is_mouse_down(button) |
True if mouse button is held (1=left, 2=middle, 3=right) |
Events (optional functions in your .lua file)
| Function | When it's called |
|---|---|
function load() |
Once at the start |
function update(dt) |
Every frame — dt is seconds since last frame |
function draw() |
Every frame after update |
function keypressed(key) |
When a key is first pressed |
function keyreleased(key) |
When a key is released |
function mousepressed(x, y, button) |
When a mouse button is clicked |
Window & Utility
| Function | What it does |
|---|---|
screen_width() |
Returns the window width |
screen_height() |
Returns the window height |
get_time() |
Returns seconds since the game started |
run_game() Options
run_game(
"mygame.lua", # path to your lua file
width=800, # window width (default 800)
height=600, # window height (default 600)
title="My Game",# window title (default "LuaGame")
fps=60 # frames per second (default 60)
)
Metadata
Release files for LuaGame 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| luagame-0.1.1.tar.gz | 4.0 kB | Without provenance | Details for luagame-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| luagame-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for luagame-0.1.1-py3-none-any.whl |
Total release size: 8.6 kB
Release files / luagame-0.1.1.tar.gz
| Download URL | luagame-0.1.1.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0d06c0e8e1476ed95cd91f5d4eb9bf2c1cdeb9ad6ed53d45e9956038d2de8fe0
|
|
BLAKE2b-256 checksum How to use checksums |
98c852e0914eea9e02de0419bf96e0c0745c6e3e0d2102afdb48a0574e20191b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.1 CPython/3.14.3 Windows/11
|
Release files / luagame-0.1.1-py3-none-any.whl
| Download URL | luagame-0.1.1-py3-none-any.whl |
|---|---|
| Size | 4.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cbe82e570a4d274be6c028e09f7ddba19fa91eaee3fcd1f56a84feeb08cb2c53
|
|
BLAKE2b-256 checksum How to use checksums |
48207b5508f2e15dfb7f4bb89bd563a11b0961989328bd5845ce966789830a17
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.1 CPython/3.14.3 Windows/11
|
Security for LuaGame 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.