how do you set conditions for a new level
The DoctorProfessor is out!
![Twitter](/assets/twitter-4e19209ef84344ee0c433f4c7bad8d49.png)
![Twitter.hover](/assets/twitter.hover-1fb19a5bafc50deace8f88eaec867845.png)
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) import java.util.List; /** * Write a description of class HoneyWorld here. * * @author (your name) * @version (a version number or a date) */ public class HoneyWorld extends World { int level; /** * Constructor for objects of class HoneyWorld. * */ public HoneyWorld() { // Create a new world with 600x400 cells with a cell size of 1x1 pixels. super(600, 400, 1); setupLevel(1); } public void setupLevel(int lvl) { removeObjects(getObjects(null)); level = lvl; if (level == 1) { //Add objects for the first level. } else if (level == 2) { //Add objects for level 2. } } public void act() { //Change Honey.class to whatever name you use. List honey = getObjects(Honey.class); if (honey.isEmpty()) { setupLevel(level+1); } } }
private boolean atGoal = false; public setAtGoal ( boolean worldsend) { atGoal = worldsend;} public getAtGoal () { return atGoal;}
wombat.setAtGoal (false);
wombat.setAtGoal(true);
if (wombat.atGoal) { Greenfoot.setWorld(new IceWorld()); //Only one world has control in a time }
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) import java.util.List; /** * Write a description of class Background here. * * @author (your name) * @version (a version number or a date) */ public class Background extends World { int level; /** * Constructor for objects of class Background. * */ public Background() { // Create a new world with 600x400 cells with a cell size of 1x1 pixels. super(850, 850, 1); prepare(); } /** * Prepare the world for the start of the program. That is: create the initial * objects and add them to the world. */ private void prepare() { setuLevel(1); } public void setuLevel(int lv1) { removeObjects(getObjects(null)); level = lv1; if (level == 1) { //Add objects for the first leve honey honey = new honey(); addObject(honey, 311, 338); honey honey2 = new honey(); addObject(honey2, 649, 60); honey honey3 = new honey(); addObject(honey3, 649, 60); honey honey4 = new honey(); addObject(honey4, 531, 549); honey honey5 = new honey(); addObject(honey5, 91, 176); honey honey6 = new honey(); addObject(honey6, 138, 429); honey honey7 = new honey(); addObject(honey7, 328, 97); honey honey8 = new honey(); addObject(honey8, 785, 475); honey honey9 = new honey(); addObject(honey9, 164, 780); honey honey10 = new honey(); addObject(honey10, 607, 308); honey honey11 = new honey(); addObject(honey11, 414, 240); honey honey12 = new honey(); addObject(honey12, 210, 164); honey honey13 = new honey(); addObject(honey13, 234, 504); honey honey14 = new honey(); addObject(honey14, 403, 389); honey honey15 = new honey(); addObject(honey15, 578, 148); honey honey16 = new honey(); addObject(honey16, 460, 74); honey honey17 = new honey(); addObject(honey17, 741, 266); honey honey18 = new honey(); addObject(honey18, 598, 699); honey honey19 = new honey(); addObject(honey19, 400, 623); honey honey20 = new honey(); addObject(honey20, 542, 416); honey honey21 = new honey(); addObject(honey21, 37, 489); honey honey22 = new honey(); addObject(honey22, 82, 236); honey honey23 = new honey(); addObject(honey23, 464, 774); honey honey24 = new honey(); addObject(honey24, 766, 671); honey honey25 = new honey(); addObject(honey25, 688, 522); honey honey26 = new honey(); addObject(honey26, 384, 478); honey honey27 = new honey(); addObject(honey27, 193, 627); honey honey28 = new honey(); addObject(honey28, 190, 295); honey honey29 = new honey(); addObject(honey29, 160, 42); honey honey30 = new honey(); addObject(honey30, 762, 134); honey honey31 = new honey(); addObject(honey31, 484, 281); honey honey32 = new honey(); addObject(honey32, 335, 198); honey honey33 = new honey(); addObject(honey33, 51, 61); honey honey34 = new honey(); addObject(honey34, 57, 681); honey honey35 = new honey(); addObject(honey35, 322, 737); Hero hero = new Hero(); addObject(hero, 67, 345); Blob blob = new Blob(); addObject(blob, 690, 358); honey33.setLocation(42, 82); honey29.setLocation(204, 43); Blob blob2 = new Blob(); addObject(blob2, 641, 788); Blob blob3 = new Blob(); addObject(blob3, 474, 155); setuLevel(1); } else if (level == 2) { //Add objects for the second level honey honey = new honey(); addObject(honey, 311, 338); honey honey2 = new honey(); addObject(honey2, 649, 60); honey honey3 = new honey(); addObject(honey3, 649, 60); honey honey4 = new honey(); addObject(honey4, 531, 549); honey honey5 = new honey(); addObject(honey5, 91, 176); honey honey6 = new honey(); addObject(honey6, 138, 429); honey honey7 = new honey(); addObject(honey7, 328, 97); honey honey8 = new honey(); addObject(honey8, 785, 475); honey honey9 = new honey(); addObject(honey9, 164, 780); honey honey10 = new honey(); addObject(honey10, 607, 308); honey honey11 = new honey(); addObject(honey11, 414, 240); honey honey12 = new honey(); addObject(honey12, 210, 164); honey honey13 = new honey(); addObject(honey13, 234, 504); honey honey14 = new honey(); addObject(honey14, 403, 389); honey honey15 = new honey(); addObject(honey15, 578, 148); honey honey16 = new honey(); addObject(honey16, 460, 74); honey honey17 = new honey(); addObject(honey17, 741, 266); honey honey18 = new honey(); addObject(honey18, 598, 699); honey honey19 = new honey(); addObject(honey19, 400, 623); honey honey20 = new honey(); addObject(honey20, 542, 416); honey honey21 = new honey(); addObject(honey21, 37, 489); honey honey22 = new honey(); addObject(honey22, 82, 236); honey honey23 = new honey(); addObject(honey23, 464, 774); honey honey24 = new honey(); addObject(honey24, 766, 671); honey honey25 = new honey(); addObject(honey25, 688, 522); honey honey26 = new honey(); addObject(honey26, 384, 478); honey honey27 = new honey(); addObject(honey27, 193, 627); honey honey28 = new honey(); addObject(honey28, 190, 295); honey honey29 = new honey(); addObject(honey29, 160, 42); honey honey30 = new honey(); addObject(honey30, 762, 134); honey honey31 = new honey(); addObject(honey31, 484, 281); honey honey32 = new honey(); addObject(honey32, 335, 198); honey honey33 = new honey(); addObject(honey33, 51, 61); honey honey34 = new honey(); addObject(honey34, 57, 681); honey honey35 = new honey(); addObject(honey35, 322, 737); Hero hero = new Hero(); addObject(hero, 67, 345); honey33.setLocation(42, 82); honey29.setLocation(204, 43); } } public void act() { List honey = getObjects(honey.class); if (honey.isEmpty()) { setuLevel(level=1); } } }