public class Level1 extends World
{
private GreenfootImage mouthOpened = new GreenfootImage("Transparent Jordan mouth opened.png");//creates a variable that the Jordan mouth opened picture is stored in.
private GreenfootImage mouthClosed = new GreenfootImage("Transparent Jordan mouth closed.png");//creates a variable that the Jordan mouth closed picture is stored in.
private Jordan[] jordans = new Jordan[getHeight()/41];//defines a variable with multiple actors inside of it.
private int JCurseCounter = 0;//sets a counter to zero at the start of the world.
private boolean changingWorld = false;
public Level1()
{
super(600, 400, 1); //Creates a new world with 600 pixels on the X axis and 400 pixels on the Y axis with a cell size of 1x1 pixels.
Alfie alfie = new Alfie();//defines alfie as a new actor so that it can be referenced from another place in the code
addObject(alfie, 20, getHeight()/2); //Adds an actor alfie into the world
for(int i = 1; i < jordans.length; i++)//Creates a for loop to add the jordans to the world and all as different names although they are added to the world in the same loop.
{
jordans[i] = new Jordan();
addObject(jordans[i], getWidth() - 25, i * 45);
}
}
public void act() // makes a void that constantly runs in the world
{
for(int noj = 1; noj <= jordans.length; noj++)
{
JCurseCounter++;
if(Greenfoot.getRandomNumber(jordans.length) == noj && changingWorld == false)
{
if(JCurseCounter >= 700)
{
JCurse jcurse = new JCurse();
addObject(jcurse, 575, noj*47);
JCurseCounter = 0;
}
if(JCurseCounter < 400 && JCurseCounter > 200)
{
jordans[noj].setImage(mouthClosed);
}
}
}
}
}
