But wherever i put it i get error messages.
// in your Run_Button class (with a World subclass called MyWorld) MyWorld world = (MyWorld)getWorld(); Textbox horizontalRangeBox = world.horizontalRangeBox; Textbox verticalRangeBox = world.verticalRangeBox;
public class Run_Button extends Actor
{
public void act()
{
if (Greenfoot.mouseClicked(this)) {
Player.a=1;
Move_Counter.moves=Move_Counter.moves+1;
Game world = (Game)getWorld();
Move_Sideways horizontalRangeBox = world.horizontalRangeBox;
Move_Sideways verticalRangeBox = world.verticalRangeBox;
}
}
}Chest chest = new Chest(); addObject(chest, a , c);
if (getObjectsAt(a, c, Chest.class).isEmpty())
{
Chest chest = new Chest();
addObject(chest, a, c);
}
else b--;import greenfoot.*;
/**
* Write a description of class Game here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Game extends World
{
private Move_Sideways horizontalRangeBox, verticalRangeBox;
public static int a =1;
public static int b=1;
public static int c=1;
public static int d=1;
public static int e=1;
public static int f=1;
public static Actor chest;
/**
* Constructor for objects of class Game.
*
*/
public Game()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(500, 500, 1);
Player player = new Player();
addObject(player, 125,125 );
Chest_counter ccounter = new Chest_counter();
addObject(ccounter, 45,150 );
Money_Counter MOcounter = new Money_Counter();
addObject(MOcounter, 45,250 );
Move_Counter Mcounter = new Move_Counter();
addObject(Mcounter, 45,300 );
Bandit_counter bcounter = new Bandit_counter();
Up_Down up = new Up_Down();
addObject(up, 133,75 );
Sideways side = new Sideways();
addObject(side, 133,25 );
addObject(bcounter, 45,200 );
Run_Button rbutton = new Run_Button();
addObject(rbutton, 375,50 );
Run run = new Run();
addObject(run, 450,50 );
for(int b =1; b<11;b++){
int a = Greenfoot.getRandomNumber(8);
int c = Greenfoot.getRandomNumber(8);
a=(a+1)*50+75;
c=(c+1)*50+75;
// starting place for player is 125,125
if(a==125&&c==125){
a=a+50;
c=c+50;
}
if (getObjectsAt(a, c, Chest.class).isEmpty())
{
Chest chest = new Chest();
addObject(chest, a, c);
}
else b--;
}
for(int d =1; d<6;d++){
int e= Greenfoot.getRandomNumber(8);
int f = Greenfoot.getRandomNumber(8);
e=(e+1)*50+75;
f=(f+1)*50+75;
if(e==125&&f==125){
e=e+50;
f=f+50;
}
if (getObjectsAt(e, f, Bandit.class).isEmpty())
{
Bandit bandit = new Bandit();
addObject(bandit, e, f);
}
else d--;
}
horizontalRangeBox = new Move_Sideways();
addObject(horizontalRangeBox,250,75);
verticalRangeBox = new
Move_Sideways();
addObject(verticalRangeBox,250,25);
}
}