Important Greenfoot Code

Key Down

270

if (Greenfoot.isKeyDown("right"))

{

setRotation(0);

move(1);

}

180

90

0

Bounce At Edge

if (isAtEdge())

{

turn(180);

}

move(1);

if (Greenfoot.getRandomNumber(10)<1)

{

turn(Greenfoot.getRandomNumber(90) - 45);

}

Random

Remove Object

if (isTouching(Apple.class))
{
removeTouching(Apple.class);
}

Play Sound

Greenfoot.playSound("pop.wav");

Stop

Greenfoot.stop();

Counter

getWorld().getObjects(Counter.class).get(0).add(1);

Stuck?

If you start typing but can't remember what commands come next, press Ctrl and Space together to show a list of all possible commands that you can use.

© CSNewbs 2020