What are the goals for each level? Level 1 is 50. Level 2 = 70. Level 3 = ? etc?


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | // class fields static int level = 0 ; // to track the level static int [] goal = { 50 , 80 , 100 }; // to specify goal at each level // in the act after 'eatLeaves' if (leavesEaten == goal[level]) { level = level + 1 ; if (level == goal.length) // are all levels complete { Greenfoot.stop(); return ; } else { Greenfoot.setWorld( new MainWorld()); return ; } } |
1 2 3 4 5 6 7 8 9 10 11 12 | if (Wombat.level == 0 ) { // add whatever } else if (Wombat.level == 1 ) { // add whatever } else if (Wombat.level == 2 ) { // add whatever } |
1 2 3 4 5 6 | public World2(Wombat wombat) { super ( 12 , 12 , 50 ); // or whatever size addObject(wombat, x, y); // replace x and y with values // add all the other objects } |
1 2 3 | if (leavesEaten == 50 ) Greenfoot.setWorld( new World2()); else if (leavesEaten == 130 ) Greenfoot.setWorld( new World3()); else if (leavesEaten == 230 ) Greenfoot.stop(); |