Skrash is a native Scratch 3.0 runtime that executes .sb3 projects. It also provides an optional Python API for control, debugging, and automation.
- GCC
- GNU Make
- Python 3 and
python3-config - SDL2 development libraries
- libzip development libraries
- pytest (for running the Python tests)
Build the native Python extension and compile the C test executables:
make
Run the complete test suite:
make testThis runs both the native C tests and the Python tests.
You can also run the test suites individually:
make ctest # Build and run C tests make pytest # Build the native extension and run Python tests
Clean generated build files:
make clean
Build the standalone player:
make play
Run it with an SB3 project:
./build/skrash-play path/to/project.sb3
Skrash's runtime is developed with Scratch 3.0 compatibility as its primary goal. Its behavior and implementation decisions are guided by:
- Scratch VM source code and behavioral tests: The official Scratch VM implementation and its test suite.
- Scratch Specification: An independent reference documenting Scratch 3.0's behavior and semantics.
- Scratch Everywhere!: An existing alternative Scratch runtime implemented in C++, primarily targeting gaming consoles and handheld platforms. It serves as a related implementation and architectural point of comparison.
The Scratch VM and Scratch Specification guide implementation decisions and behavioral compatibility. Scratch Everywhere! is included as a related runtime for architectural context.
The Python API can be used to load and control Scratch projects programmatically.
import skrash project = skrash.load("game.sb3") player = project.sprites["Player"] score = project.variables["Score"] @skrash.when_green_flag_clicked def start(): player.show() player.x = 0 player.y = 0 player.direction = 90 score.value = 0 player.say("Let's play!") player.move(50) score.value += 1 project.run()
See the Python API documentation for details about the currently available API.
For additional ideas about how the Python API could evolve, see Python API Ideas. This file is a collection of design ideas inspired by the way the official Scratch editor organizes projects, sprites, the stage, and variables. It is not documentation of implemented features or a specification of the current API.
See Todo.md for the detailed list of implemented Scratch blocks and remaining work.
Contributions are welcome! Please read the Contributing Guide before opening an issue or submitting a pull request.
Skrash is licensed under the MIT License.
