-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLevel1.java
More file actions
75 lines (70 loc) · 2.34 KB
/
Level1.java
File metadata and controls
75 lines (70 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.List;
/**
* Write a description of class Level1 here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Level1 extends ScrollingWorld
{
Mobby mobby;
PowerBar powerBar;
HealthBar healthBar;
public double power;
public boolean resetPower;
public boolean returning;
private GreenfootSound bkgMusic;
public Level1(boolean returningFromLVL2)
{
super("kitchen3times.png", 7600);
returning = returningFromLVL2;
mobby = new Mobby();
powerBar = new PowerBar();
healthBar = new HealthBar();
bkgMusic = new GreenfootSound("Level 1.mp3");
shiftWorld(0);
prepare();
bkgMusic.playLoop();
}
private void prepare()
{
if (!returning) {
addObject(mobby, getWidth() / 2, getHeight() - 240/2 - 50);
addObject(powerBar, getWidth() / 2, 200);
addObject(healthBar, getWidth() / 2, 100);
PileOfBoxes pileOfBoxes0 = new PileOfBoxes();
addObject(pileOfBoxes0, 2275, 415);
PileOfBoxes pileOfBoxes1 = new PileOfBoxes();
addObject(pileOfBoxes1, 4505, 415);
Chef Chef0 = new Chef();
addObject(Chef0,3400,365);
Chef Chef1 = new Chef();
addObject(Chef1,3900,365);
Chef Chef2 = new Chef();
addObject(Chef2,4300,365);
Chef Chef3 = new Chef();
addObject(Chef3,5000,365);
Chef Chef4 = new Chef();
addObject(Chef4,5500,365);
Chef Chef5 = new Chef();
addObject(Chef5,5800,365);
}
if (returning) {
shiftWorld(-5850);
addObject(mobby, 800, getHeight() - 240/2 - 50);
addObject(powerBar, getWidth() / 2, 200);
addObject(healthBar, getWidth() / 2, 100);
}
}
public void act()
{
healthBar.setLocation(mobby.getX(), mobby.getY() - 175);
powerBar.setLocation(mobby.getX(), mobby.getY() - 150);
if (xOffset <= -5868) {
Level2 level2 = new Level2(false);
Greenfoot.setWorld(level2);
bkgMusic.stop();
}
}
}