danpost wrote...
NewbJava wrote...
I think this is correct nowpublic class MeteorsWorld extends MyWorld
{
public MeteorsWorld()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(600, 400, 1);
prepare();
}
public void addMeteor()
{
addObject(new Meteors(),getWidth()-1,Greenfoot.getRandomNumber(getHeight()));
}
private void prepare()
{
Rocket Rocket = new Rocket();
addObject(Rocket,100,200);
Rocket.setLocation(70,200);
addObject(scoreDisplay,55,380);
addObject(highScoreDisplay,525,25);
}
public void Switchscreen()
{
boolean noRockets = getObjects(Rocket.class).isEmpty();
if (noRockets == true)
{
Greenfoot.setWorld(new Playagain());
}
}
}import greenfoot.*;
public class MyWorld extends World
{
static Actor scoreDisplay;
static Actor highScoreDisplay;
public static int score;
static int highScore;
public MyWorld()
{
super(600, 400, 1, false);
scoreDisplay = new Scoreboard();
highScoreDisplay = new HighScore();
score = -1;
highScore = -1;
adjustScore(1);
}
static void adjustScore(int amt)
{
score += amt;
GreenfootImage img = new GreenfootImage("Score: "+score, 24, Color.RED, Color.BLACK);
if (score > highScore)
{
highScore = score;
img = new GreenfootImage("High score: "+highScore, 24, Color.RED, Color.BLACK);
highScoreDisplay.setImage(img);
}
}
public void act()
{
Greenfoot.setWorld(new MeteorsWorld());
}
}
public MyWorld(int w, int h, int c, boolean b)
{
super(w, h, c, b);
}public MyWorld(int w, int h, int c, boolean b)
{
super(w, h, c, b);
}
public class MyWorld extends World
{
static Actor scoreDisplay;
static Actor highScoreDisplay;
static int score;
static int highScore;
public MyWorld()
{
super(800, 600, 1);
scoreDisplay = new SimpleActor();
highScoreDisplay = new SimpleActor();
score = -1;
highScore = -1;
adjustScore(1);
}
public MyWorld(int w, int h, int c)
{
super(w, h, c);
}
static void adjustScore(int amt)
{
score += amt;
GreenfootImage img = new GreenfootImage("Score: "+score, 24, Color.RED, new Color(0, 0, 0, 0));
scoreDisplay.setImage(img);
if (score > highScore)
{
highScore = score;
img = new GreenfootImage("High score: "+highScore, 24, Color.RED, new Color(0, 0, 0, 0));
highScore.setImage(img);
}
}
public void act()
{
Greenfoot.setWorld(new MeteorWorld());
}
}import greenfoot.*;
public class MyWorld extends World
{
static Actor scoreDisplay;
static Actor highScoreDisplay;
public static int score;
static int highScore;
public MyWorld()
{
super(600, 400, 1, false);
scoreDisplay = new SimpleActor();
highScoreDisplay = new SimpleActor();
score = -1;
highScore = -1;
adjustScore(1);
}
public MyWorld(int w, int h, int c)
{
super(w, h, c);
}
static void adjustScore(int amt)
{
score += amt;
GreenfootImage img = new GreenfootImage("Score: "+score, 24, Color.RED, new Color(0, 0, 0, 0));
scoreDisplay.setImage(img);
if (score > highScore)
{
highScore = score;
img = new GreenfootImage("High score: "+highScore, 24, Color.RED, new Color(0, 0, 0, 0));
highScore.setImage(img);
}
}
public void act()
{
Greenfoot.setWorld(new MeteorsWorld());
}
}