Skip to main content

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 zombies
  • platformer.py - a simple platformer with gravity
  • shooter.py - a top-down shooter example

Core API overview

Game loop and scenes

  • Game creates the window and runs the main loop
  • Scene represents a screen or state in your game
  • GameObject is the base class for entities
  • Group updates 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fligengine-0.3.0.tar.gz (55.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fligengine-0.3.0-py3-none-any.whl (60.8 kB view details)

Uploaded Python 3

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

Hashes for fligengine-0.3.0.tar.gz
Algorithm Hash digest
SHA256 0a8db9d1ebe0425d594ff865c9064b7bdb470fd3d763216c32d58b71d6e342ff
MD5 52e0b87ea017aea1ca8bff003e642d2f
BLAKE2b-256 bebec9b30fc723b43fb1c5b97074de29a6f4895e1df554a3d9cbcf78b90133f5

See more details on using hashes here.

Provenance

The following attestation bundles were made for fligengine-0.3.0.tar.gz:

Publisher: publish.yml on fligma/FligEngine

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for fligengine-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0207e7d81104059e26df189393080fbf4f2076e3e5aa6b31673284a0212a6dff
MD5 d2c5af906efd10bb71396dba12d0a67c
BLAKE2b-256 e8c42a705b2337c4813855f50cfadeea8e4aa31d291ffb167600e6c989415f8e

See more details on using hashes here.

Provenance

The following attestation bundles were made for fligengine-0.3.0-py3-none-any.whl:

Publisher: publish.yml on fligma/FligEngine

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page