public class equation extends mover
{
public int flag=0,random=10,i;
private GreenfootImage image1;
private GreenfootImage image2;
private GreenfootImage image3;
private GreenfootImage image4;
private GreenfootImage image5;
private GreenfootImage image6;
private GreenfootImage image;
/**
* Act - do whatever the equation wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void movingEquation()
{ setLocation(getX()+2,getY()-2);}
public int starting()
{random=Greenfoot.getRandomNumber(6);
flag=flag+1;
return random; }
public void act()
{
// Add your action code here.
image= new GreenfootImage("background.PNG");
setImage(image);
image1= new GreenfootImage("equation1.PNG");
image2= new GreenfootImage("equation2.JPG");
image3= new GreenfootImage("equation3.png");
image4= new GreenfootImage("equation4.png");
image5= new GreenfootImage("equation5.png");
image6= new GreenfootImage("equation6.png");
if(Greenfoot.isKeyDown("enter"))
i=starting();
if(i==0)
setImage(image1);
else if(i==1)
setImage(image2);
else if(i==2)
setImage(image3);
else if(i==3)
setImage(image4);
else if(i==4)
setImage(image5);
else if(i==5)
setImage(image6);
if(flag!=0)
movingEquation();
if(atWorldEdge())
{ World W = getWorld();
W.removeObjects(W.getObjects(equation.class)); }
}
}

