Metadata-Version: 2.4
Name: jwarol
Version: 0.3.3
Summary: 2D game engine for Python with physics, collision detection, and texture support
Home-page: https://github.com/ruslan/jwarol
Author: ruslan
Author-email: ruslan <ruslan@example.com>
License: MIT
Project-URL: Homepage, https://github.com/ruslan/jwarol
Project-URL: Repository, https://github.com/ruslan/jwarol
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: C++
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: author
Dynamic: home-page
Dynamic: license-file

# Jwarol Engine

2D game engine for Python built with C++ and pybind11. Includes object type system, physics, collision detection, texture support and OpenGL rendering.

## Features

- **Object Type System**: Create objects of different types (PLAYER, ITEM, GUI, OBJECT)
- **Physics Engine**: Gravity simulation and collision detection
- **Boundary Checking**: Verify if objects are within world bounds
- **Texture Loading**: Load and manage textures
- **OpenGL Rendering**: Hardware-accelerated 2D rendering
- **Window Management**: Create and manage game windows

## Installation

```bash
pip install jwarol==0.3.2
```

## API Reference

### ObjectType Enum

Define the type of game object:

```python
jwarol.ObjectType.OBJECT  # Generic object
jwarol.ObjectType.PLAYER  # Player character
jwarol.ObjectType.ITEM    # Collectible item
jwarol.ObjectType.GUI     # GUI element
```

### Engine Class

Main class for the game engine.

#### Methods

| Method | Parameters | Returns | Description |
|--------|-------------|---------|-------------|
| `__init__()` | None | Engine | Create new engine instance |
| `init(width, height, title)` | width (int), height (int), title (str) | bool | Initialize game window (800x600 example). Returns True on success |
| `create_object(x, y, w, h, type)` | x (float), y (float), w (float), h (float), type (ObjectType) | int | Create new object, returns unique object ID |
| `is_object(id, type)` | id (int), type (ObjectType) | bool | Check if object with `id` is of `type` |
| `check_collision(id1, id2)` | id1 (int), id2 (int) | bool | Check if two objects collide |
| `is_open()` | None | bool | Check if window is still open |
| `clear(r, g, b)` | r (float), g (float), b (float) | None | Clear screen with color (0.0-1.0 range) |
| `draw_rect(id, r, g, b)` | id (int), r (float), g (float), b (float) | None | Draw object by ID with color |
| `update()` | None | None | Update screen (swap buffers) |
| `close()` | None | None | Close engine and free resources |

## Usage Examples

### Basic Example

```python
import jwarol

# Initialize engine
engine = jwarol.Engine()
engine.init(800, 600, "My Game")

# Create player object
player = engine.create_object(100, 100, 50, 50, jwarol.ObjectType.PLAYER)

# Game loop
while engine.is_open():
    engine.clear(0.2, 0.2, 0.2)  # Grey background
    engine.draw_rect(player, 0.0, 1.0, 0.0)  # Green player
    engine.update()

engine.close()
```

### Multiple Objects & Collision Detection

```python
import jwarol

engine = jwarol.Engine()
engine.init(800, 600, "Collision Example")

# Create objects of different types
player = engine.create_object(100, 100, 50, 50, jwarol.ObjectType.PLAYER)
enemy = engine.create_object(300, 100, 50, 50, jwarol.ObjectType.OBJECT)
item = engine.create_object(200, 300, 30, 30, jwarol.ObjectType.ITEM)
gui = engine.create_object(10, 10, 100, 30, jwarol.ObjectType.GUI)

# Check object types
print(f"Player is PLAYER: {engine.is_object(player, jwarol.ObjectType.PLAYER)}")  # True
print(f"Enemy is OBJECT: {engine.is_object(enemy, jwarol.ObjectType.OBJECT)}")    # True
print(f"Item is ITEM: {engine.is_object(item, jwarol.ObjectType.ITEM)}")          # True
print(f"GUI is GUI: {engine.is_object(gui, jwarol.ObjectType.GUI)}")              # True

while engine.is_open():
    engine.clear(0.2, 0.2, 0.2)
    
    # Draw objects with different colors
    engine.draw_rect(player, 0.0, 1.0, 0.0)   # Green - Player
    engine.draw_rect(enemy, 1.0, 0.0, 0.0)     # Red - Enemy
    engine.draw_rect(item, 1.0, 1.0, 0.0)      # Yellow - Item
    engine.draw_rect(gui, 0.0, 0.0, 1.0)       # Blue - GUI
    
    # Check collision between player and enemy
    if engine.check_collision(player, enemy):
        print("Player hit enemy!")
    
    engine.update()

engine.close()
```

### Physics & Boundary Checking (Internal)

The engine includes a physics system with gravity and boundary checking:

```cpp
// C++ internal API (not yet exposed to Python)
physics.apply_gravity(obj, delta_time);  // Apply gravity to object
physics.check_boundary(obj, world_width, world_height);  // Check if object is in bounds
physics.check_collision_with(obj, objects);  // Check collision with other objects
```

## Project Structure

```
's/
├── main.cpp           # Main engine code with Python bindings
├── object_types.h/.cpp  # Object type system
├── physics.h/.cpp     # Physics engine
├── texture.h/.cpp     # Texture management
├── setup.py          # Build configuration
├── pyproject.toml    # Project metadata
├── LICENSE           # MIT License
└── README.md         # This file
```

## Author

**ruslan**

## License

MIT License - see [LICENSE](LICENSE) file.

## Links

- PyPI: https://pypi.org/project/jwarol/0.3.2/
- Issues: https://github.com/ruslan/jwarol/issues
