Metadata-Version: 2.4
Name: pyscrh
Version: 0.1.2
Summary: A tiny Scratch-style sprite library built on pygame, for people moving from Scratch to Python.
Author-email: 魔丸编程 <17516332069@163.com>
License: MIT License
        
        Copyright (c) 2026 魔丸编程
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), 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.
        
Project-URL: Homepage, https://github.com/CutePandaXJK/pyscrh
Project-URL: Repository, https://github.com/CutePandaXJK/pyscrh
Keywords: scratch,pygame,game,sprite,education,beginner
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Games/Entertainment
Classifier: Topic :: Education
Classifier: Intended Audience :: Education
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pygame>=2.0
Dynamic: license-file

# pyscrh

A tiny, **Scratch-style** sprite library built on [pygame](https://www.pygame.org/),
made for people moving from Scratch to Python.

Every Scratch block you know has a short Python equivalent — no game loop,
no event handling, no surface juggling to remember.

## Install

```bash
pip install pyscrh
```

(Requires Python 3.8+ and pygame, which is installed automatically.)

## Quick start

```python
import pyscrh

apple = Sprite("apple.png")     # load an image (PNG with transparency)
apple.turnway = "lr"            # flip left-right when bouncing

def forever():
    apple.move(5)               # walk 5 steps in the current direction
    apple.edgeb()               # bounce off the screen edge
    # stop_all()                # call this anywhere to quit the game

clickGF()                       # start the game
```

Just `import pyscrh` and you're done — `Sprite`, `clickGF`, `stop_all`,
`WIDTH` and `HEIGHT` are available directly, just like `import pgzrun`.

That's it. The apple walks right, bounces off the right edge, walks left,
bounces off the left edge, and repeats.

## Scratch → Python cheat sheet

| Scratch block | pyscrh |
| --- | --- |
| move 10 steps | `sprite.move(10)` |
| turn 15° clockwise | `sprite.turnright(15)` |
| turn 15° counter-clockwise | `sprite.turnleft(15)` |
| go to x: y: | `sprite.gotoxy(x, y)` |
| go to random position | `sprite.goto("r")` |
| go to another sprite | `sprite.goto("other_name")` |
| glide 1 sec to x: y: | `sprite.glidexy(1, x, y)` |
| glide to another sprite | `sprite.glideto(1, "other_name")` |
| point in direction 90 | `sprite.point(90)` |
| point towards mouse | `sprite.pointtow("m")` |
| point towards another sprite | `sprite.pointtow("other_name")` |
| if on edge, bounce | `sprite.edgeb()` |

## How it works

You only write one required function:

- `forever()` — called once every frame, like Scratch's *forever* block.
  Put `sprite.move(...)`, `edgeb()`, etc. in here. No `dt` parameter
  needed; the library handles timing.

An optional `draw()` is also called every frame, *after* all sprites are
drawn, if you want extra drawing (text, backgrounds, etc.).

Call `clickGF()` to start, and `stop_all()` to close the window and quit.
pyscrh handles the window, clock, event loop and rendering for you.

## API reference

### `Sprite(image_path, name="")`

Create a sprite from an image file.

| Method | Description |
| --- | --- |
| `move(steps)` | Walk `steps` pixels in the current direction. |
| `turnright(deg)` / `turnleft(deg)` | Rotate by `deg` degrees. |
| `gotoxy(x, y)` | Jump to `(x, y)`. |
| `goto("r")` / `goto("m")` | Jump to a random spot / the mouse. |
| `glidexy(sec, x, y)` | Glide to `(x, y)` over `sec` seconds. |
| `glideto(sec, "r")` / `glideto(sec, "m")` | Glide to a spot / the mouse. |
| `point(deg)` | Set direction to `deg` degrees. |
| `pointtow("r")` / `pointtow("m")` | Face a random direction / the mouse. |
| `edgeb()` | Bounce off the screen edge. |

| Attribute | Description |
| --- | --- |
| `x`, `y` | Center position (read or write). |
| `angle` | Direction in degrees (0 = right, 90 = down). |
| `turnway` | `"r"` rotate-bounce, `"lr"` flip-bounce, `"n"` no bounce. |

## License

MIT
