sorry I guess I forgot to put it up, I hope you don't mind me putting up everything I have I just don't know what's causing the problem
public class Blob extends Actor
{
public void act()
{
move(2);
turn(1);
checkKeys();
Actor coin = getOneIntersectingObject(Coin.class);
if(coin!=null)
{
World myWorld = getWorld();
myWorld.removeObject(coin);
Sky sky = (Sky)myWorld;
}
// If we are touching a pipe, then Game over
if (getOneIntersectingObject(SpaceBug.class) !=null)
{
displayGameOver();
}
}
private void displayGameOver ()
{
GameOver gameOver = new GameOver();
getWorld().addObject(gameOver, getWorld().getWidth()/2,getWorld().getHeight()/2);
}
private void checkKeys()
{
if(Greenfoot. isKeyDown("left")){
setLocation(getX() - 1, getY());
}
if(Greenfoot.isKeyDown("right")){
setLocation(getX() + 1, getY());
}
if(Greenfoot.isKeyDown("up")){
setLocation(getX(), getY() - 1);
}
if(Greenfoot.isKeyDown("down")){
setLocation(getX(), getY() +1);
}
}
}
public void act()
{
move(Greenfoot.getRandomNumber(5));
turn(Greenfoot.getRandomNumber(20) - 10);
if(getX()==0) {
setLocation(getWorld().getWidth(), getY());
}
if(getX()==getWorld().getWidth()-2) {
setLocation(0, getY());
}
if(getY()==1) {
setLocation(getX(), getWorld().getHeight());
}
if(getY()==getWorld().getHeight()) {
setLocation(getX(), 0);
}
}
}
public class Sky extends World
{
int coinCounter = 0;
int blobCounter = 0;
int score = 0;
int FIRST_COIN = 240;
Score scoreObj = null;
/**
* Constructor for objects of class MyWorld.
*
*/
public Sky()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(800, 600, 1);
prepare();
}
public void act()
{
coinCounter++;
if (coinCounter % 100 == 0)
{
createCoin();
}
if (coinCounter >= FIRST_COIN)
{
if (blobCounter % 100 == 0)
{
score++;
scoreObj.setScore(score);
}
blobCounter++;
}
}
private void createCoin()
{
//Create Coin Object
Coin coin = new Coin();
}
private void prepare()
{
// set paint order
setPaintOrder(GameOver.class, Score.class, Blob.class, SpaceBug.class);
//Create a Blob Object
Blob blob = new Blob();
//Add Blob to our world
addObject (blob, 35, 300);
//Add a coin to the world
Coin coin = new Coin();
addObject(coin, 0, Greenfoot.getRandomNumber(getHeight()));
//Add a SpaceBug to the edge of the world
SpaceBug spaceBug = new SpaceBug();
int x = getWidth();
int y = Greenfoot.getRandomNumber(getHeight());
addObject(spaceBug,x,y);
}
}
public class Score extends Actor
{
/**
* Act - do whatever the Score wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
//Constructor
public Score()
{
GreenfootImage newImage = new GreenfootImage(50, 50);
setImage(newImage);
}// end score
public void setScore(int score)
{
GreenfootImage newImage = getImage();
newImage.clear();
Font f = new Font("Arial",Font.PLAIN,32);
newImage.setFont(f);
Color c = new Color(127, 127, 127, 127);
newImage.setColor(c);
newImage.fill();
newImage.setColor(Color.black);
newImage.drawString("" + score, 16, 36);
setImage(newImage);
}
}
public class GameOver extends Actor
{
/**
* Act - do whatever the GameOver wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
// Add your action code here.
}
}