Metadata-Version: 2.4
Name: pygameeasysup
Version: 0.1.0
Summary: PYGAMEEASY — pygame without the pain: window, shapes, images, sound and input in a few lines.
License: MIT
Keywords: pygame,game,easy,wrapper,beginner,2d
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Education
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Games/Entertainment
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pygame>=2.1.0
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"
Dynamic: license-file

# PYGAMEEASY

pygame without the pain. A window, shapes, images, sound and input in a few readable lines.

```bash
pip install pygame-easy
```

The package is installed as `pygame-easy` and imported as `pygameeasy`.

## Quick start

```python
import pygameeasy

fps = 60

snakeMusic = pygameeasy.volume("volume.mp3", "music")
snakeClick = pygameeasy.volume("volume2.mp3", "volume")

snake = pygameeasy.ObjectIM(100, 200, "photo.png")
snakeZAD = pygameeasy.Object("circle", 100, 200, "#000000")

wp = pygameeasy.wp(fps)

while True:
    wp.checkforclose()

    snake.render(100, 100)
    snakeZAD.render(100, 100)

    if pygameeasy.check("keyboard", "w"):
        snakeClick.volume(44)

    if pygameeasy.check("mouse", "left"):
        snakeClick.volume(44)

    wp.render()
```

## API

### `pygameeasy.wp(fps, width=800, height=600, title="PYGAMEEASY", background="#FFFFFF", resizable=False, fullscreen=False)`

Creates the window and runs the frame loop.

| Member | Description |
| --- | --- |
| `checkforclose()` | Processes events. Closes the program when the window is closed. Call it first in every frame. |
| `render()` | Shows the frame, holds the FPS and clears the screen for the next frame. Returns `dt` in seconds. |
| `dt` | Duration of the previous frame in seconds, for frame-rate independent movement. |
| `width`, `height` | Current window size. |
| `screen` | The underlying `pygame.Surface`, for anything not covered by the library. |
| `events` | Raw pygame events of the current frame. |
| `title(text)` | Changes the window title. |
| `close()` | Quits pygame and exits the program. |

### `pygameeasy.Object(shape, sizeX, sizeY, color)`

A colored shape. `shape` is `"circle"` (an ellipse when `sizeX != sizeY`), `"rect"` (aliases `"rectangle"`, `"square"`) or `"triangle"`. `color` accepts `"#RRGGBB"` and pygame color names. The `color` attribute can be changed at any time.

`render(x, y, center=False)` draws the shape with its top-left corner at `x, y`, or with its center there when `center=True`. It returns the `pygame.Rect` that was drawn.

### `pygameeasy.ObjectIM(sizeX, sizeY, file)`

An image scaled to `sizeX × sizeY`. Transparency is kept. `render(x, y, center=False)` works like `Object.render`.

### `pygameeasy.volume(file, kind, level=100)`

Loads audio. `level` is 0–100.

`kind="music"` starts playing immediately and restarts by itself when it ends. `.volume(level)` changes its loudness. Also available: `pause()`, `resume()`, `stop()`, `play()`. pygame has a single music stream, so a second `"music"` object replaces the first.

`kind="volume"` is a sound effect. `.volume(level)` sets the loudness and plays the sound; while it is still playing, repeated calls (for example from a held key) only update the loudness and do not stack copies. Also available: `play()` to force a start, `stop()`, `playing`, `level`.

### `pygameeasy.check(device, name, once=False)`

`device="keyboard"`: any pygame key name (`"w"`, `"space"`, `"left"`, `"up"`, `"f1"`, ...), plus the aliases `"esc"`, `"enter"`, `"ctrl"`, `"shift"`, `"alt"`.

`device="mouse"`: `"left"`, `"middle"`, `"right"`, `"scrollup"`, `"scrolldown"`.

By default it is `True` for as long as the key or button is held. With `once=True` it is `True` only in the single frame where it was pressed (scroll is always per frame).

`pygameeasy.mouse_position()` returns `(x, y)`.

## Development

```bash
pip install -e ".[dev]"
pytest
python -m build
twine check dist/*
twine upload dist/*
```

Tests run headless (`SDL_VIDEODRIVER=dummy`, `SDL_AUDIODRIVER=dummy`).

## License

MIT
