import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Lander here.
*
* @author (spy9144)
* @version (a version number or a date)
*/
public class Lander extends Actor
{
/**
* Act - do whatever the ladybug wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
// Add your action code here.
if (Greenfoot.isKeyDown("left"))
{
turn(-10); // turn left
}
if (Greenfoot.isKeyDown("right"))
{
turn(+10); // turn right
}
move(2);
// our new behavior code is going here
// make the LadyBug eat any Leaf on this square Actor leaf = getOneObjectAtOffset(0,0,Leaf.class); if (leaf != null)
{
World w = getWorld();
w.removeObject (apple); }
}
}