public Level5(){ // Create a new world with 600x400 cells with a cell size of 1x1 pixels. super(600, 400, 1); Cover.backgroundMusic.stop(); prepare(); }//end constructor
public Level5(){ // Create a new world with 600x400 cells with a cell size of 1x1 pixels. super(600, 400, 1); Cover.backgroundMusic.stop(); prepare(); }//end constructor
public Level5(Cover world1) { // other stuff world1.stopBackgroundMusic(); // other stuff }
public void stopBackgroundMusic() { backgroundMusic.stop(); }
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Main player. Gets controlled by user. * * @author (Quinn Sapp) * @version (11 July 2013) */ public class MainPlayer extends Animal { private Counter counter; public MainPlayer(Counter pointCounter){ counter = pointCounter; }// end of Counter public void act(){ checkKeyPress(); lookForPoint(); lookForFinish(); gameOver(); checkNextLevel(); checkNextLevel2(); checkNextLevel3(); checkNextLevel4(); }// end act public void checkKeyPress(){ if (Greenfoot.isKeyDown("left")){ turn(-4); }//end if if (Greenfoot.isKeyDown("right")){ turn(4); }//end if if (Greenfoot.isKeyDown("space")){ move(2); }//end if }//end checkKeys public void lookForPoint(){ if (canSee(Point.class)){ eat(Point.class); counter.add(1); Greenfoot.playSound("slurp.wav"); }//end if if(counter.getValue() >= 35){ }//end if } //end lookForPoint public void lookForFinish(){ if (canSee(Finish.class)){ eat(Point.class); counter.add(1); Greenfoot.playSound("slurp.wav"); }//end if if(counter.getValue() >= 35){ }//end if } //end lookForFinish public void gameOver(){ if (counter.getValue() >= 15) Greenfoot.setWorld(new Level2()); }//end gameOver public void checkNextLevel(){ if (getOneIntersectingObject(Finish.class) != null) { //reached the end object; //start the new level; Greenfoot.setWorld(new MainWorld()); }//end if }//end checkNextLevel public void checkNextLevel2(){ if (getOneIntersectingObject(Finish2.class) != null) { //reached the end object; //start the new level; Greenfoot.setWorld(new Level3()); }//end if }//end checkNextLevel2 public void checkNextLevel3(){ if (getOneIntersectingObject(Finish3.class) != null) { //reached the end object; //start the new level; Greenfoot.setWorld(new Level4()); }//end if }//end checkNextLevel3 public void checkNextLevel4(){ if (getOneIntersectingObject(Finish4.class) != null) { //reached the end object; //start the new level; Greenfoot.setWorld(new Level5());// this is where the error is i believe i have to put something in the () but idk what, can you please help? }//end if }//end checkNextLevel4 }//end MainPlayer
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * This is level 5 of 5 you need to complete in order to win the Game. * This is a bonus level, to just have fun collect as many points as you want because by completing * the first 4 levels you have won the game. * @author (Quinn Sapp) * @version (11 July 2013) */ public class Level5 extends World { /** * Constructor for objects of class MainWorld. * */ public Level5(Cover cover){ // Create a new world with 600x400 cells with a cell size of 1x1 pixels. super(600, 400, 1); cover.stopBackgroundMusic(); prepare(); }//end constructor
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * This entales the instructions, objectives of the game and the START to begin the game. * * @author (Quinn Sapp) * @version (11 July 2013) */ public class Cover extends World { GreenfootSound backgroundMusic = new GreenfootSound("Track 02.wav"); /** * Constructor for objects of class Cover. * */ public Cover() { // Create a new world with 600x400 cells with a cell size of 1x1 pixels. super(600, 400, 1); backgroundMusic.playLoop(); prepare(); } public void stopBackgroundMusic(){ backgroundMusic.stop(); }
public class Level5 extends World { private GreenfootSound bgMusic; public Level5(GreenfootSound bgMusic){ super(600, 400, 1); this.bgMusic = bgMusic;//save the GreenfootSound object in this world; if (bgMusic != null) { bgMusic.stop();//only execute in Level5; } prepare(); } public GreenfootSound getBgSound() { return bgSound; } }
public void checkNextLevel(){ if (getOneIntersectingObject(Finish.class) != null) { //reached the end object; //start the new level; //get the bgSound object; GreenfootSound bgSound = null; World world = getWorld(); if (world instanceof MainWorld) { bgSound = ((MainWorld) world).getBgSound(); } else if (world instanceof Level2) { bgSound = ((Level2) world).getBgSound(); } else if (world instanceof Level3) { bgSound = ((Level3) world).getBgSound(); } else if (world instanceof Level4) { bgSound = ((Level4) world).getBgSound(); } else if (world instanceof Level5) { bgSound = ((Level5) world).getBgSound(); } Greenfoot.setWorld(new MainWorld(bgSound)); }//end if }//end checkNextLevel
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Main player. Gets controlled by user. * * @author (Quinn Sapp) * @version (11 July 2013) */ public class MainPlayer extends Animal { private Counter counter; public MainPlayer(Counter pointCounter){ counter = pointCounter; }// end of Counter public void act(){ checkKeyPress(); lookForPoint(); lookForFinish(); gameOver(); checkNextLevel(); }// end act public void checkKeyPress(){ if (Greenfoot.isKeyDown("left")){ turn(-4); }//end if if (Greenfoot.isKeyDown("right")){ turn(4); }//end if if (Greenfoot.isKeyDown("space")){ move(2); }//end if }//end checkKeys public void lookForPoint(){ if (canSee(Point.class)){ eat(Point.class); counter.add(1); Greenfoot.playSound("slurp.wav"); }//end if if(counter.getValue() >= 35){ }//end if } //end lookForPoint public void lookForFinish(){ if (canSee(Finish.class)){ eat(Point.class); counter.add(1); Greenfoot.playSound("slurp.wav"); }//end if if(counter.getValue() >= 35){ }//end if } //end lookForFinish public void gameOver(){ if (counter.getValue() >= 15) Greenfoot.setWorld(new Level2()); }//end gameOver public void checkNextLevel(){ if (getOneIntersectingObject(Finish.class) != null) { GreenfootSound bgSound = null; World world = getWorld(); if (world instanceof MainWorld) { bgSound = ((MainWorld) world).getBgSound(); } else if (world instanceof Level2) { bgSound = ((Level2) world).getBgSound(); } else if (world instanceof Level3) { bgSound = ((Level3) world).getBgSound(); } else if (world instanceof Level4) { bgSound = ((Level4) world).getBgSound(); } else if (world instanceof Level5) { bgSound = ((Level5) world).getBgSound(); } Greenfoot.setWorld(new MainWorld(bgSound)); }//end if }//end checkNextLevel }//end MainPlayer
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * This is level 5 of 5 you need to complete in order to win the Game. * This is a bonus level, to just have fun collect as many points as you want because by completing * the first 4 levels you have won the game. * @author (Quinn Sapp) * @version (11 July 2013) */ public class Level5 extends World{ private GreenfootSound bgMusic; /** * Constructor for objects of class MainWorld. * */ public Level5(GreenfootSound bgMusic){ // Create a new world with 600x400 cells with a cell size of 1x1 pixels. super(600, 400, 1); this.bgMusic = bgMusic; if(bgMusic != null){ bgMusic.stop(); } prepare(); }//end constructor public GreenfootSound getBgSound(){ return bgSound; }