Skip to main content

A Scratch-like library for Python using Pygame

Project description

Welcome to ScratchyPy!

ScratchyPy is a graphics-focused library for Python using Pygame. It uses the same vocabulary as the popular Scratch block-based programming lanugage.

Meet the mascot, Axel, the friendly axolotl.

logo image

[!NOTE] ScratchyPy is a work-in-progress and does not have a stable release yet. The API is mostly in place, but there could be further changes that change behavior.

Who's it for?

If you feel like you've mastered the graphical programming of Scratch, or started to hit some limitations, then ScratchyPy may be a good next step into the world of system programming.

(LEGAL) This project is not affiliated with Scratch in any way. Scratch(TM) is a trademark of the Scratch Team. Scratch is developed by the Lifelong Kindergarten Group at the MIT Media Lab. See scratch.mit.edu.

How to install

ScratchyPy requires Python 3.8 or higher.

Install with pip3 install scratchypy

ScratchyPy is built on top of the pygame library, which will be installed as a dependency.

What you need to know

Some basic knowledge of Python is required. There are many good introductory tutorials on the internet that can teach you the basics.

Knowledge of pygame is not required, but you may end up learning some as you go.

Quick Start

This Scratch code... ... is equivalent to this ScratchyPy

scratch block image

from scratchypy import *
def startItUp(stage):
    sprite1 = Sprite("assets/axolotl1.png")
    stage.add(sprite1)
    sprite1.turn(45)
    sprite1.move(50)
start(startItUp)

You can run this fully-annotated example and see many others in the /examples folder.

Features

ScratchyPy does not aim to reproduce Scratch exactly and faithfully. Python, Pygame, and general UI programming patterns work differently and this library is more of a bridge into that world using familiar concepts.

See the almost-complete Scratch mapping.

The generated code documentation is continuously published at https://jtmarkoise.github.io/scratchypy/

Bonus Features

There are several areas where ScratchyPy adds on some bonus functionality on top of Scratch capabilities.

  • TextSprite
  • AnimatedSprite
  • Multiple stages and substages
  • Direct messages with parameters
  • stage.when_drawing to hook in pygame drawing

Sharing

What makes Scrach fun is its social coding aspect. You can easily try out others' work and it is safe to do so in the confines of a browser.

Python is a powerful system language. It can create and delete files, do networking and downloads, and generally do anything your computer account can do. This makes it dangerous to try out programs from people you don't know or trust, since they could very well delete all your files or install a virus.

[!CAUTION] Before running a shared program, make sure you trust the person who sent it to you.

TODO: Safe alternatives?

Limitations

See the Python design page for expert information TBD

Support

In short, there is nothing official. I hope you will enjoy learning Python and programming, and that a friendly community of support evolves.

If you find bug with the library itself, please open an issue on GitHub. Enhancement requests are welcome too (even better with a patch provided!).

TODO

  • colors

How to make images / transparency

Sprite with single costume:

sp = Sprite("larry.png")

Sprite with multiple costumes:

sp = Sprite(["explosion1.png", "explosion2.png"])

Loading sprites with setting transparent color:

costume = image.load("curly.bmp", color.WHITE)
sp = Sprite(costume)

Convenient way to load separate images in an animation: image01.png, image02.png, etc. Make the black background transparent.

frames = image.loadPattern("animation/image*.png", Color.BLACK)
sp = Sprite(frames)

Expanding further

  • other libs like pygame-menu and UI

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scratchypy-0.1.2.tar.gz (989.1 kB view details)

Uploaded Source

Built Distribution

scratchypy-0.1.2-py3-none-any.whl (25.4 kB view details)

Uploaded Python 3

File details

Details for the file scratchypy-0.1.2.tar.gz.

File metadata

  • Download URL: scratchypy-0.1.2.tar.gz
  • Upload date:
  • Size: 989.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for scratchypy-0.1.2.tar.gz
Algorithm Hash digest
SHA256 5a091e4ba7a685a965649c65b2dcd0be5c81bbee8ff73865c8c62e18be585f0f
MD5 85e1b10bf6a1b17ac7c95e7de37c97ca
BLAKE2b-256 a8c809fcfc2d4132c69d2371af7d24ec2f68085037ecb4fd54a524610f4b3f84

See more details on using hashes here.

File details

Details for the file scratchypy-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: scratchypy-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 25.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for scratchypy-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 cea399117504d2506e6c96a368460f6a932ff0541302ab1533579fecfa79f9ab
MD5 48badbb478cf648abe7a5105dbebde29
BLAKE2b-256 1677f2a15b3ae25e0f4dca0a60efbe48388a29f0ae4e6601360f7580b7c612f9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page