Cool. I'll get back to you in the morning with some results.
import greenfoot.*;
/**
* My World! :)
*/
public class Space extends World
{
private Health healthbar = new Health();
private int health;
private Counter theCounter;
public int intropause = 150;
public int rulespause = 600;
/**
* Default constructor that prepares the world.
*/
public Space()
{
super(800, 600, 1);
prepare();
adjustHealth(5);
}
public Counter getCounter()
{
return theCounter;
}
// Checks the width and height of the Rocket.
public int x = (new Rocket()).getImage().getWidth();
public int y = (new Rocket()).getImage().getHeight();
// Sets the delay for the Asteroid at 0.
private int delayAsteroid=650;
/**
* Checks the delay of the Asteroid class, and if it's at zero, adds another Asteroid at a
* an x coordinate of 40 degrees, and a random y coordinate.
*/
public void act()
{
if (delayAsteroid>0 && --delayAsteroid>0)
{
return;
}
addObject(new Asteroid(), 30, (Greenfoot.getRandomNumber(570)));
delayAsteroid = (Greenfoot.getRandomNumber(60));
}
public void prepare()
{
Rules rules = new Rules();
addObject(new Rules(), 400, 300);
Intro intro = new Intro();
addObject(new Intro(), 400, 300);
if(intropause>0)
{
intropause--;
}
else
{
if(intropause == 0)
{
removeObject(intro);
}
}
if(rulespause>0)
{
rulespause--;
}
if(rulespause == 0)
{
addObject(healthbar, 690, 34);
Rocket rocket = new Rocket();
addObject(new Rocket(270),410,510);
theCounter = new Counter();
addObject(theCounter, 76, 30);
removeObject(rules);
}
}
public void adjustHealth(int changeAmount)
{
health += changeAmount;
if (health > 5) health = 5;
if (health < 0) health = 0;
healthbar.setImage("health"+health+".png");
if (health == 0)
{
}
}
}public void prepare()
{
Intro intro = new Intro();
addObject(intro, getWidth()/2, getHeight()/2);
Greenfoot.delay(150);
removeObject(intro);
Rules rules = new Rules();
addObject(rules, getWidth()/2, getHeight()/2);
Greenfoot.delay(600);
removeObject(rules);
//add all the object for the game
Greenfoot.start();
}