Metadata-Version: 2.5
Name: sypy-engine-beginner
Version: 0.2.1
Summary: A beginner-friendly 2D game engine built with Python and Pygame
Author: Methuka Koralage
License: MIT License
        
        Copyright (c) 2026 Methuka
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files, to deal in the Software
        without restriction, including without limitation the rights to use, copy,
        modify, merge, publish, distribute, sublicense, and/or sell copies of the
        Software, and to permit persons to whom the Software is furnished to do so,
        subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Requires-Python: >=3.10
Requires-Dist: pygame==2.6.1
Description-Content-Type: text/markdown

# SyPy

### A lightweight 2D game engine for Python and Pygame

**SyPy 0.2.1** is a beginner-friendly 2D game engine built with Python and Pygame.

It provides a simple API for creating entities, physics, collisions, platforms, cameras, and game logic without forcing you to deal with the engine's internal systems.

---

## Features

* 🟦 2D entities
* 🧱 Solid objects
* 🪜 One-way platforms
* 🏃 Basic movement
* 🪂 Gravity
* 🦘 Jumping
* 💥 Collision detection
* 🧊 Friction
* 🚀 Maximum movement speed
* 🎥 Camera system
* 🔄 Resizable window
* 🏷️ Entity tags
* 🎮 Custom entity update functions
* 🖥️ Simple rendering system
* 📦 Clean engine API
* 🐍 Built completely with Python
* ⚡ Powered by Pygame

---

# Installation

Install SyPy using pip:

```bash
pip install sypy
```

Upgrade to the latest version:

```bash
pip install --upgrade sypy
```

Check the installed version:

```python
import engine

print(engine.__version__)
```

Expected:

```text
0.2.1
```

---

# Quick Start

Create a file called `main.py`:

```python
from engine import Engine

game = Engine(
    800,
    600,
    "My SyPy Game"
)

game.run()
```

Run it:

```bash
python main.py
```

---

# Creating an Entity

Entities are the main objects in your game.

```python
player = game.add_entity(
    "player",
    position=(100, 300),
    size=(40, 60),
    color=(50, 150, 255),
    tags=["player"]
)
```

You can configure the entity using the built-in methods:

```python
player.set_gravity(1800)
player.set_jump(650)
player.set_friction(0.85)
player.set_max_speed(400)
```

---

# Creating Solids

Create a floor:

```python
game.add_solid(
    "floor",
    position=(0, 550),
    size=(800, 50)
)
```

Create a platform:

```python
game.add_solid(
    "platform",
    position=(300, 400),
    size=(200, 25)
)
```

You can also change its color:

```python
game.add_solid(
    "platform",
    position=(300, 400),
    size=(200, 25),
    color=(100, 180, 100)
)
```

---

# One-Way Platforms

One-way platforms allow the player to pass through them from below but land on top.

```python
game.add_solid(
    "platform",
    position=(300, 400),
    size=(200, 25),
    one_way=True
)
```

This makes it possible to create:

* Platforms
* Floating islands
* Jump-through floors
* Platformer levels
* Multi-level maps

---

# Player Movement

SyPy allows you to give an entity its own update function.

```python
import pygame


def player_update(player, dt, game):

    keys = pygame.key.get_pressed()

    if keys[pygame.K_a]:
        player.velocity.x -= 1200 * dt

    if keys[pygame.K_d]:
        player.velocity.x += 1200 * dt

    if keys[pygame.K_SPACE]:
        player.jump()


player.set_update(player_update)
```

The engine automatically calls the function every frame.

---

# Complete Example

```python
import pygame

from engine import Engine


game = Engine(
    800,
    600,
    "SyPy Platformer"
)


player = game.add_entity(
    "player",
    position=(100, 300),
    size=(40, 60),
    color=(50, 150, 255),
    tags=["player"]
)

player.set_gravity(1800)
player.set_jump(650)
player.set_friction(0.85)
player.set_max_speed(400)


game.add_solid(
    "floor",
    position=(0, 550),
    size=(800, 50),
    color=(80, 80, 80)
)


game.add_solid(
    "platform",
    position=(300, 400),
    size=(200, 25),
    color=(100, 180, 100),
    one_way=True
)


def player_update(player, dt, game):

    keys = pygame.key.get_pressed()

    if keys[pygame.K_a]:
        player.velocity.x -= 1200 * dt

    if keys[pygame.K_d]:
        player.velocity.x += 1200 * dt

    if keys[pygame.K_SPACE]:
        player.jump()


player.set_update(player_update)


game.set_camera_target(player)

game.run()
```

---

# Camera

You can make the camera follow an entity:

```python
game.set_camera_target(player)
```

The camera smoothly follows the target.

You can also use the camera directly:

```python
game.camera.world_to_screen(
    player.position
)
```

Convert screen coordinates back to world coordinates:

```python
game.camera.screen_to_world(
    (400, 300)
)
```

---

# Entity Tags

Entities can have tags:

```python
player = game.add_entity(
    "player",
    tags=["player"]
)
```

Check a tag:

```python
if player.has_tag("player"):
    print("This is the player!")
```

Add a tag:

```python
player.add_tag("enemy")
```

Remove a tag:

```python
player.remove_tag("enemy")
```

---

# Jumping

Entities can jump when they are on the ground:

```python
player.jump()
```

Check whether an entity is grounded:

```python
if player.is_on_ground():
    print("Player is on the ground")
```

Configure jump strength:

```python
player.set_jump(650)
```

---

# Physics

SyPy 0.2.1 includes basic built-in physics.

### Gravity

```python
player.set_gravity(1800)
```

### Friction

```python
player.set_friction(0.85)
```

### Maximum Speed

```python
player.set_max_speed(400)
```

### Velocity

You can directly modify velocity when needed:

```python
player.velocity.x += 100
player.velocity.y = -500
```

---

# Engine Structure

SyPy separates the game from the engine internals.

```text
project/
│
├── main.py
│
└── engine/
    ├── __init__.py
    ├── engine.py
    │
    ├── core/
    │   ├── entity.py
    │   └── solid.py
    │
    └── camera/
        └── camera.py
```

Your game code should normally live in:

```text
main.py
```

while SyPy handles the engine systems.

---

# API

## Engine

### `Engine()`

Creates a new game.

```python
game = Engine(
    800,
    600,
    "My Game"
)
```

### `add_entity()`

```python
player = game.add_entity(
    "player",
    position=(100, 100),
    size=(50, 50),
    color=(255, 255, 255),
    tags=["player"]
)
```

### `add_solid()`

```python
floor = game.add_solid(
    "floor",
    position=(0, 550),
    size=(800, 50)
)
```

### `set_camera_target()`

```python
game.set_camera_target(player)
```

### `run()`

```python
game.run()
```

---

# Entity API

```python
entity.set_update(function)
entity.set_gravity(1800)
entity.set_jump(650)
entity.set_friction(0.85)
entity.set_max_speed(400)

entity.jump()

entity.add_tag("enemy")
entity.remove_tag("enemy")
entity.has_tag("enemy")

entity.is_on_ground()
```

---

# Solid API

```python
solid.stop_pass(entity)
```

Solids also support:

```python
solid.one_way
solid.position
solid.size
solid.rect
solid.color
```

---

# Camera API

```python
camera.apply(rect)

camera.apply_object(entity)

camera.world_to_screen(position)

camera.screen_to_world(position)
```

---

# Why SyPy?

SyPy is designed to make game-engine programming easier to understand.

Instead of writing complicated systems just to create a player, you can do:

```python
player = game.add_entity(
    "player",
    position=(100, 300),
    size=(40, 60)
)
```

Then configure it:

```python
player.set_gravity(1800)
player.set_jump(650)
player.set_max_speed(400)
```

The goal is to keep the API:

**Simple → Flexible → Understandable**

---

# Version

Current version:

```text
SyPy 0.2.1
```

---

# Roadmap

Future SyPy versions may include:

* 🎞️ Sprite rendering
* 🖼️ Animation system
* 🗺️ Tilemaps
* 🎵 Audio system
* 🎮 Input manager
* 🧩 Component system
* 🎬 Scene system
* ✨ Particle system
* 🖥️ UI system
* 💾 Save/load system
* 🔲 Hitboxes and triggers
* 🏃 Improved movement
* 📐 Slopes
* 🪜 Moving platforms
* 🔄 Better collision handling
* 🛠️ Debug tools
* 📦 Asset management

---

# Requirements

SyPy currently uses:

```text
Python
Pygame
```

Install Pygame if necessary:

```bash
pip install pygame
```

---

# License

SyPy is an open-source project.

Use it to experiment, learn, and build your own games.

---

# Made With Python

SyPy is built with ❤️ using Python and Pygame.

**SyPy 0.2.1 — Build your game your way.**
