-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLevel1.java
executable file
·55 lines (48 loc) · 1.31 KB
/
Level1.java
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
import greenfoot.GreenfootImage;
/**
* World for Level1 of the game
*
* @author Jimmy
* @version June 13 2024
*/
public class Level1 extends Level {
private final Player player;
private final int[] worldSize = {2700, 720};
private final String background = "2dSpaceBackground.png";
private Orb orb;
/**
* Constructor for objects of class Level1.
*/
public Level1() {
super();
scroll = new ImgScroll(this, new GreenfootImage(background), worldSize[0], worldSize[1]);
spawnFloor(scroll);
addObject(player = new Player(), 130, 135);
addObject(coinLabel, 1100, 10);
addObject(saveButton, getWidth() - 100, 40);
updateCoin();
// Individual Block Placement
int[][] blockGeneration = loadLevel(1);
spawnTerrain(blockGeneration);
}
public void act() {
followPlayer(player);
updateCoin();
saveButton.setLocation(getWidth() - 100, 40);
checkSaveButton();
loseLife();
checkNext();
}
private void loseLife() {
if (player.touchingSpike()) {
player.changeHP(-5);
setHP(totalHP - 5);
}
}
public void stopped() {
TitleScreen.stopBGM();
}
public void started() {
TitleScreen.playBGM();
}
}