Hello,
What should i add to my code so as to keep the best score on the main menu. And if i beat it,to update?
Thanks!
public static int highScore30, highScore60, highScore90;
public static void finalScore30(int score)
{
if (score > highScore30) highScore30 = score;
}import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class MainMenu here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class MainMenu extends World
{
/**
* Constructor for objects of class MainMenu.
*
*/
public static int highScore30, highScore60, highScore90;
public MainMenu()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(1500,800,1);
Items();
Intro();
}
void Items()
{
addObject(new thirty_seconds(),750,400);
addObject(new sixty_seconds(),750,500);
addObject(new ninety_seconds(),750,600);
}
void Intro()
{
GreenfootSound sound = new GreenfootSound("START.wav");
Greenfoot.playSound("START.wav");
}
public static void finalScore30(int score)
{
if (score > highScore30) highScore30 = score;
}
public static void finalScore60(int score)
{
if (score > highScore60) highScore60 = score;
}
public static void finalScore90(int score)
{
if (score > highScore90) highScore90 = score;
}
}
sound.play();
HiScores();
private void HiScores()
{
GreenfootImage text = new GreenfootImage("30-second High Score: "+highScore30, 30, TEXT_COLOR, TRANSPARENT_COLOR);
getBackground().drawImage(text, 300, 50);
text = new GreenfootImage("60-second High Score: "+highScore60, 30, TEXT_COLOR, TRANSPARENT_COLOR);
getBackground().drawImage(text, 400, 50);
text = new GreenfootImage("90-second High Score: "+highScore90, 30, TEXT_COLOR, TRANSPARENT_COLOR);
getBackground().drawImage(text, 500, 50);
}import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.awt.Color;
/**
* Write a description of class MainMenu here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class MainMenu extends World
{
/**
* Constructor for objects of class MainMenu.
*
*/
public static int highScore30, highScore60, highScore90;
public MainMenu()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(1500,800,1);
Items();
Intro();
HiScores();
}
void Items()
{
addObject(new thirty_seconds(),750,400);
addObject(new sixty_seconds(),750,500);
addObject(new ninety_seconds(),750,600);
HiScores();
}
void Intro()
{
GreenfootSound sound = new GreenfootSound("START.wav");
Greenfoot.playSound("START.wav");
}
public static void finalScore30(int score)
{
if (score > highScore30)
{
highScore30 = score;
}
}
public static void finalScore60(int score)
{
if (score > highScore60)
{
highScore60 = score;
}
}
public static void finalScore90(int score)
{
if (score > highScore90)
{
highScore90 = score;
}
}
private void HiScores()
{
GreenfootImage text = new GreenfootImage("30-second High Score: "+highScore30, 30, TEXT_COLOR, TRANSPARENT_COLOR);
getBackground().drawImage(text, 300, 50);
text = new GreenfootImage("60-second High Score: "+highScore60, 30, TEXT_COLOR, TRANSPARENT_COLOR);
getBackground().drawImage(text, 400, 50);
text = new GreenfootImage("90-second High Score: "+highScore90, 30, TEXT_COLOR, TRANSPARENT_COLOR);
getBackground().drawImage(text, 500, 50);
}
}
private static final Color TEXT_COLOR = new Color(255,255,255); private static final Color TRANSPARENT_COLOR = new Color(0,0,0,0);
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.awt.Color;
/**
* Write a description of class MainMenu here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class MainMenu extends World
{
/**
* Constructor for objects of class MainMenu.
*
*/
private static final Color TEXT_COLOR = new Color(255,255,255);
private static final Color TRANSPARENT_COLOR = new Color(0,0,0,0);
public static int highScore30, highScore60, highScore90;
public MainMenu()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(1500,800,1);
Items();
Intro();
}
void Items()
{
addObject(new thirty_seconds(),750,400);
addObject(new sixty_seconds(),750,500);
addObject(new ninety_seconds(),750,600);
}
void Intro()
{
GreenfootSound sound = new GreenfootSound("START.wav");
Greenfoot.playSound("START.wav");
}
public static void finalScore30(int score)
{
if (score > highScore30)
{
highScore30 = score;
}
}
public static void finalScore60(int score)
{
if (score > highScore60)
{
highScore60 = score;
}
}
public static void finalScore90(int score)
{
if (score > highScore90)
{
highScore90 = score;
}
}
}
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.awt.Color;
/**
* Write a description of class MainMenu here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class MainMenu extends World
{
/**
* Constructor for objects of class MainMenu.
*
*/
private static final Color TEXT_COLOR = new Color(255,255,255);
private static final Color TRANSPARENT_COLOR = new Color(0,0,0,0);
public static int highScore30, highScore60, highScore90;
public MainMenu()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(1500,800,1);
Items();
Intro();
}
void Items()
{
addObject(new thirty_seconds(),750,400);
addObject(new sixty_seconds(),750,500);
addObject(new ninety_seconds(),750,600);
}
void Intro()
{
GreenfootSound sound = new GreenfootSound("START.wav");
Greenfoot.playSound("START.wav");
}
public static void finalScore30(int score)
{
if (score > highScore30)
{
highScore30 = score;
}
}
public static void finalScore60(int score)
{
if (score > highScore60)
{
highScore60 = score;
}
}
public static void finalScore90(int score)
{
if (score > highScore90)
{
highScore90 = score;
}
}
}