Metadata-Version: 2.4
Name: fligengine
Version: 0.3.0
Summary: A pygame-inspired 2D game engine built on tkinter + PIL
Author: Fligma
License-Expression: MIT
Project-URL: Homepage, https://github.com/fligma/fligengine
Project-URL: Documentation, https://github.com/fligma/fligengine#readme
Project-URL: Repository, https://github.com/fligma/fligengine
Project-URL: Issues, https://github.com/fligma/fligengine/issues
Keywords: game,engine,2d,pygame,tkinter,gamedev
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Games/Entertainment
Classifier: Topic :: Software Development :: Libraries :: pygame
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: Pillow>=9.0.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: black>=22.0.0; extra == "dev"
Requires-Dist: build>=1.0.0; extra == "dev"
Dynamic: license-file

# 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:

```bash
pip install fligengine
```

Install from the source tree:

```bash
git clone https://github.com/fligma/fligengine
cd fligengine
pip install -e .
```

## Quickstart

```python
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

```python
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

```python
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

```python
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

```python
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

```python
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.
