import greenfoot.*;
public class MyWorld extends World // focuses on displaying of the score
{
static Actor scoreDisplay; // all static variable because they rest once the game is finished
static Actor highScoreDisplay;
public static int score;
static int highScore;
public MyWorld() // screen size and sets variable values,
{
super(600, 400, 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 trial) // score resseting and high score being saved for every round and being replaced if score is largr than high score
{
score += trial;
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));
highScoreDisplay.setImage(img);
}
}
public void act() // getting from the MeteorsWorld() method in the sub class
{
Greenfoot.setWorld(new MeteorsWorld());
}
}
