VictorNorman / ScratchFoot

A Scratch emulation layer in Greenfoot.
4 stars 1 forks source link

ScratchFoot v0.5

(12 August 2016)

A Scratch emulation layer for Greenfoot.

ScratchFoot provides a subclass of World and subclass of Actor which make available much of the functionality of Scratch in Greenfoot.
Using ScratchFoot, you should be able to convert many Scratch programs to use Greenfoot. This may be useful for

Here is an example of how s2g.py converts a Scratch script to its equivalent Greenfoot Java code:

converts to code

public class TennisBall extends Scratch
{
    public TennisBall()
    {
        addCostume("1.png", "tennisball");
        switchToCostume(1);
        setSizeTo(55);
        pointInDirection(90);
        setRotationStyle(RotationStyle.ALL_AROUND);
        whenFlagClicked("whenFlagClickedCb0");
    }

    public void whenFlagClickedCb0(Sequence s)
    {
        clear();
        penUp();
        Stage.xvel.set(3);
        Stage.yvel.set(0);
        goTo( -186, 97);
        penDown();
        // repeat until code
        while (! (isTouchingEdge()))
        {
            if (getY() < -140)
            {
                Stage.yvel.set((Stage.yvel.get() * -0.8));
            }
            changeXBy(Stage.xvel.get());
            changeYBy(Stage.yvel.get());
            Stage.yvel.set(Stage.yvel.get() + -1);
            wait(s, 0.2);
            yield(s);   // allow other sequences to run
        }
    }

ScratchFoot emulates the following nice features from Scratch:

ScratchFoot limitations:


How to Convert a Scratch program to a ScratchFoot (i.e., Greenfoot) scenario.

The file s2g.py is a python 3 program that will try to automatically convert a downloaded Scratch project into a Greenfoot scenario.

In order to make this work, you need to install these programs on your computer:

Procedure for converting your Scratch project to Greenfoot:

For more information about the API provided by ScratchFoot and what to expect when you convert a Scratch project to a Greenfoot scenario, see this wiki page.

ScratchFoot has been created by Victor Norman at Calvin College with great help from student Jordan Doorlag.