I have other world used as menu and the like and they still run just not that one. hmm still looking will gt back in a few mins
import greenfoot.*;
/**
* Write a description of class Game here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Game extends World
{
public Move_Sideways horizontalRangeBox, verticalRangeBox;
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 g = Greenfoot.getRandomNumber(8);
int c = Greenfoot.getRandomNumber(8);
g=(g+1)*50+75;
c=(c+1)*50+75;
// starting place for player is 125,125
if(g==125&&c==125){
g=g+50;
c=c+50;
}
if (getObjectsAt(g, c, Chest.class).isEmpty())
{
Chest chest = new Chest();
addObject(chest, g, 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);
}
}
import greenfoot.*;
/**
* Write a description of class Run_Button here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Run_Button extends Actor
{
/**
* Act - do whatever the Run_Button wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
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;
//System.out.println("\nHorizontal range given: '"+horizontalRangeBox.getValue()+"'\nVertical range given: '"+verticalRangeBox.getValue()+"'");
// x and y and the value to change position of player.
// Player.x=horizontalRangeBox.getValue()
// player y=verticalRangeBox.getValue()
}
}
}
if (getObjectsAt(g, c, Chest.class).isEmpty())
{
Chest chest = new Chest();
addObject(chest, g, c);
}
else b--;
if (getObjectsAt(e, f, Bandit.class).isEmpty())
{
Bandit bandit = new Bandit();
addObject(bandit, e, f);
}
else d--;
}
GreenfootImage image = getImage();
image.scale(30, 30);
setImage(image);