A pygame-inspired 2D game engine built on tkinter + PIL
Project description
FligEngine
FligEngine is a lightweight, pygame-inspired 2D game engine for Python. It is built on tkinter and Pillow, so you can create windows, draw graphics, manage scenes, and build simple games without needing a heavyweight dependency stack.
It is designed to feel familiar to anyone coming from pygame, while staying simple enough for hobby projects, prototypes, and small commercial games.
Features
- Window and display management
- 2D drawing primitives: rectangles, circles, lines, polygons, text, and images
- Keyboard and mouse input handling
- Scene-based game structure
- Game objects, sprites, groups, and collision helpers
- Camera support for scrolling worlds
- Tilemaps for level creation
- Physics, particles, timers, animation, and transforms
- Audio playback, UI widgets, and vector math
Installation
Install from PyPI:
pip install fligengine
Install from the source tree:
git clone https://github.com/fligma/fligengine
cd fligengine
pip install -e .
Quickstart
from FligEngine import *
class Player(GameObject):
def start(self):
self.speed = 200
self.tag = "player"
def update(self, dt):
if self.input.key_down("w"):
self.y -= self.speed * dt
if self.input.key_down("s"):
self.y += self.speed * dt
if self.input.key_down("a"):
self.x -= self.speed * dt
if self.input.key_down("d"):
self.x += self.speed * dt
def draw(self, display):
display.draw_rect(int(self.x), int(self.y), 32, 32, fill=color.RED)
class MainScene(Scene):
def start(self):
self.add_object(Player(100, 100))
def update(self, dt):
super().update(dt)
if self.input.key_pressed("escape"):
self.game.quit()
game = Game("My Game", 800, 600)
game.run(MainScene())
Example projects
The examples directory contains a few starter projects:
dodge.py- dodge zombiesplatformer.py- a simple platformer with gravityshooter.py- a top-down shooter example
Core API overview
Game loop and scenes
Gamecreates the window and runs the main loopScenerepresents a screen or state in your gameGameObjectis the base class for entitiesGroupupdates and draws many objects at once
Display and drawing
from FligEngine import *
display.clear(color.BLACK)
display.draw_rect(10, 10, 100, 80, fill=color.RED)
display.draw_circle(200, 150, 40, fill=color.BLUE)
display.draw_line(0, 0, 200, 200, color=color.WHITE)
display.draw_text("Hello", 20, 20, color=color.WHITE, size=24)
Input
input = InputHandler(display.tk_root)
input.update()
if input.key_down("w"):
player.y -= 200 * dt
if input.key_pressed("space"):
player.jump()
if input.mouse_pressed("left"):
print("clicked")
Physics and tilemaps
from FligEngine import physics, Tilemap
world = physics.World(gravity=(0, 500))
body = world.create_body(100, 100, 32, 32)
body.apply_impulse(0, -250)
world.update(dt)
level = Tilemap([[1, 1, 1], [1, 0, 0]], tile_size=32)
level.set_tile_color(1, color.GRAY)
Audio, particles, and UI
from FligEngine import audio, ui, ParticleSystem
particles = ParticleSystem()
particles.explosion(400, 300)
audio.init()
sound = audio.Sound("shoot.wav")
sound.play()
button = ui.Button("Start", x=100, y=100)
button.on_click = lambda: print("clicked")
Colors, vectors, timers, and transforms
from FligEngine import Color, Vector2, Timer, Cooldown, transform, color
Color(255, 128, 0)
Color.from_hex("#FF5500")
Vector2(10, 20)
Timer(2.0)
Cooldown(0.5)
transform.rotate(surface, 45)
Requirements
- Python 3.8+
- Pillow
- tkinter (included with most Python installs)
License
FligEngine is released under the MIT license.
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 fligengine-0.3.0.tar.gz.
File metadata
- Download URL: fligengine-0.3.0.tar.gz
- Upload date:
- Size: 55.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a8db9d1ebe0425d594ff865c9064b7bdb470fd3d763216c32d58b71d6e342ff
|
|
| MD5 |
52e0b87ea017aea1ca8bff003e642d2f
|
|
| BLAKE2b-256 |
bebec9b30fc723b43fb1c5b97074de29a6f4895e1df554a3d9cbcf78b90133f5
|
Provenance
The following attestation bundles were made for fligengine-0.3.0.tar.gz:
Publisher:
publish.yml on fligma/FligEngine
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fligengine-0.3.0.tar.gz -
Subject digest:
0a8db9d1ebe0425d594ff865c9064b7bdb470fd3d763216c32d58b71d6e342ff - Sigstore transparency entry: 2040078015
- Sigstore integration time:
-
Permalink:
fligma/FligEngine@d537e4e36266ea3834a378898d6e1db7606e97e0 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/fligma
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d537e4e36266ea3834a378898d6e1db7606e97e0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file fligengine-0.3.0-py3-none-any.whl.
File metadata
- Download URL: fligengine-0.3.0-py3-none-any.whl
- Upload date:
- Size: 60.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0207e7d81104059e26df189393080fbf4f2076e3e5aa6b31673284a0212a6dff
|
|
| MD5 |
d2c5af906efd10bb71396dba12d0a67c
|
|
| BLAKE2b-256 |
e8c42a705b2337c4813855f50cfadeea8e4aa31d291ffb167600e6c989415f8e
|
Provenance
The following attestation bundles were made for fligengine-0.3.0-py3-none-any.whl:
Publisher:
publish.yml on fligma/FligEngine
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fligengine-0.3.0-py3-none-any.whl -
Subject digest:
0207e7d81104059e26df189393080fbf4f2076e3e5aa6b31673284a0212a6dff - Sigstore transparency entry: 2040078055
- Sigstore integration time:
-
Permalink:
fligma/FligEngine@d537e4e36266ea3834a378898d6e1db7606e97e0 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/fligma
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d537e4e36266ea3834a378898d6e1db7606e97e0 -
Trigger Event:
push
-
Statement type: