top of page

Greenfoot Code Glossary

This code will work for Version 2.4.2 which is used in Component 2 of the 2016 WJEC/Edquas specification.

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 - (Write this code when an object is removed)

Counter counter = (Counter) getWorld().getObjects(Counter.class).get(0);

counter.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.

bottom of page