//Code for my World where trash falls downwards to the chef
public class RealGame extends World
{
HealthBar healthBar = new HealthBar();
public RealGame()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(800, 600, 1);
prepare();
}
//its not void, bc healthbar is returning the healthbar to the realgame when it is called
public HealthBar gethealthBar()
{
return healthBar;
}
/**
* Prepare the world for the start of the program.
* That is: create the initial objects and add them to the world.
*/
private void prepare()
{
Back back = new Back();
addObject(back,75,40);
Cheese cheese = new Cheese();
addObject(cheese,404,62);
Counter counter = new Counter();
addObject(counter,75,114);
HealthBar healthBar = new HealthBar();
addObject(healthBar,639,50);
healthBar.setLocation(706,39);
healthBar.setLocation(702,36);;
Chef chef = new Chef();
addObject(chef,382,527);
Trash trash = new Trash();
addObject(trash,310,96);
}
int iCounter = 0;
public void act()
{
iCounter++;
if(iCounter == 60)
{
iCounter = 0;
Trash myTrash = new Trash();
addObject(new Trash(), Greenfoot.getRandomNumber(getWidth()),0);
}
}
}

