Hi ALL,
I want to create a title page, that once pressed leads to an instructions page, that once pressed turns into the game....at the bottom I have my attempts commented out, but im real confused.
public class FrogWorld extends World
{
Counter counter = new Counter("Score: "); //creates string to display you cumulative score
Counter FrogLife = new Counter("Frogs Remaining: "); //Creats counter displaying the amont of frogs keft
private GreenfootSound Music = new GreenfootSound("Greenfoot Song.mp3"); //adds a background song to the game
public FrogWorld(){
super(600, 600, 1); //create the area for the game to be played
createWorldObjects(); // calls the method createWorldObjects
}
public void act() {
//Background();
//showMessage();
scores(); //calls the method of scores
}
public void countHit(FrogsHit hit){
counter.add(hit.getCount());
}
public void lose(){
if(FrogLife.getValue()==1){ // if you have no lives left
addObject(new ScoreLose(counter.getValue()), getWidth()/2, getHeight()/2); //displays a scoreboard from the ScoreLose class
Greenfoot.playSound("Lose.wav"); //plays a clip that says "you lose"
Greenfoot.stop(); // and stops the greenfoot game
}
else{ //if you have more than a life left
FrogLife.subtract(1); //it takes away one life from
}
}
public void win(){
if(FrogLife.getValue()>=1 && FrogLife.getValue() < 10){ // if you have more than 1 life and less than 10
FrogLife.add(1); //you are given an extra life when heart is hit
}
}
private void createWorldObjects(){
addObject(new FrogHunter(), 300,300); //calls frog hunter and starts baseball bat in middle of scree
addObject(counter, 90, 560); //shows the counter of score at places it on screen
addObject(FrogLife, 170, 540); // shows "frogs left: " on screen and places in bottom corner
FrogLife.add(5); //adds 5 lives to begin the game
}
public void scores(){
int score = counter.getValue(); // creates variable score which is the value of the counter
int num = Greenfoot.getRandomNumber(100); // sets random number between 1-100
int num1 = Greenfoot.getRandomNumber(100); // sets random number between 1-100
int num2 = Greenfoot.getRandomNumber(200); // sets random number between 1-200
int num3 = Greenfoot.getRandomNumber(750); // sets random number between 1-750
if (score <= 250 ){ //whenever score is below or at 250
if(num > 1 && num < 5){
addObject(new SwimmingFrog(), Greenfoot.getRandomNumber(599), 600); //adds a frog whenever the random number is between 1-5
}
}
if (score > 250 && score <= 500){ //whenever score is between 250-500
if(num > 1 && num < 6){
addObject(new SwimmingFrog(), Greenfoot.getRandomNumber(599), 600); //adds a frog whenever the random number is between 1-6
}
if(num2 == 1 || num2 == 2){
addObject(new Fish(), Greenfoot.getRandomNumber(599), 600); //adds a fish when the random number is equal to 1 or 2
}
}
if (score > 500 && score <= 2000){ //whenever score is between 500 and 2000
if(num > 1 && num < 7){
addObject(new SwimmingFrog(), Greenfoot.getRandomNumber(599), 600); //adds a frog whenever the random number is between 1-7
}
if(num2 == 1 || num2 == 2){
addObject(new Fish(), Greenfoot.getRandomNumber(599), 600); //adds a fish when the random number is equal to 1 or 2
}
if(num2 == 3 || num2 == 4){
addObject(new PolarBear(), Greenfoot.getRandomNumber(599), 600); //adds a polar bear when the random number is equal to 3 or 4
}
}
if(score >= 0 && score < 3000){ //between 0 and 3000 or anytime game is being played
if(num3 == 375){
addObject(new Fly(), 600, Greenfoot.getRandomNumber(599)); // adds a fly whenever random number 3 equals 1
}
}
if (score > 2000 ){ //whenever score is above 2000
if(num > 1 && num < 8){
addObject(new SwimmingFrog(), Greenfoot.getRandomNumber(599), 600); //adds a frog whenever the random number is between 1-8
}
if(num2 == 1 || num2 == 2){
addObject(new Fish(), Greenfoot.getRandomNumber(599), 600); //adds a fish when the random number is equal to 1 or 2
}
if(num2 == 3|| num2 == 4){
addObject(new PolarBear(), Greenfoot.getRandomNumber(599), 600); //adds a polar bear when the random number is equal to 3 or 4
}
}
if (score == 499 || score == 999 || score == 1499 ||score == 1999 || score == 2499){
addObject(new Life(), Greenfoot.getRandomNumber(599), 600); //adds a new heart (for new life) every 500 points
}
if((FrogLife.getValue()>=1 && score >= 3000)){ //if you have a life and a score above 3000
addObject(new ScoreWin(counter.getValue()), getWidth()/2, getHeight()/2); //displays score board from the score win class
Greenfoot.playSound("pop.wav"); //plays a winnner sound
Greenfoot.stop(); //stops the game
}
}
public void started(){
Music.playLoop(); //startes playing the music
}
public void stopped(){
Music.stop(); //stops playing the music
}
// public void Background(){
// setBackground(new GreenfootImage("images.png"));
// }
// public void showMessage(){
// Font font = new Font("Comic sans", Font.BOLD, 30);
// GreenfootImage BackGround = getBackground();
// BackGround.setColor(Color.BLACK);
// BackGround.setFont(font);
// BackGround.drawString("Press Anywhere To Start", 120, 25);
// }
// public void createBackground(MouseInfo press){
// while(G.mouseClicked(press))
// {
// setBackground(new GreenfootImage("LilyPad.jpg"));
// }
// while(Greenfoot.mouseClicked(press))
// {
// setBackground(new GreenfootImage("Pond.jpg"));
// }
// }
// public void winner(){
// int score = counter.getValue();
// if((FrogLife.getValue()>=1 && score >= 5000)){
// addObject(new ScoreWin(counter.getValue()), getWidth()/2, getHeight()/2);
// Greenfoot.playSound("Pop.wav");
// Greenfoot.stop();
// }
// }
