-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLevel.java
More file actions
93 lines (75 loc) · 1.89 KB
/
Level.java
File metadata and controls
93 lines (75 loc) · 1.89 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package sample;
import java.util.ArrayList;
import java.util.List;
/**
* Classe abstraite pour représenter un niveau.
*
*/
public abstract class Level {
/**
* À quel point on est avancés dans le level
*/
protected double scroll;
/**
* Dimensions du niveau visible à l'écran
*/
protected double screenWidth, screenHeight;
/**
* Obstacles du niveau
*/
protected List<Obstacle> obstacles;
/**
* Items et champignon final
*/
protected List<Item> items;
protected Mushroom victoryMushroom;
public Level(double screenWidth, double screenHeight) {
this.screenWidth = screenWidth;
this.screenHeight = screenHeight;
obstacles = new ArrayList<>();
items = new ArrayList<>();
}
public double getScroll() {
return scroll;
}
public double getScreenWidth() {
return screenWidth;
}
public double getScreenHeight() {
return screenHeight;
}
public List<Obstacle> getObstacles() {
return obstacles;
}
public List<Item> getPowerUps() {
return items;
}
public void tick(double dt) {
for (Obstacle o : obstacles) {
o.tick(dt);
}
for (Item p : items) {
p.tick(dt);
}
victoryMushroom.tick(dt);
}
public void incrementScroll(double scroll) {
this.scroll += scroll;
}
/**
* Retourne les entités dans le niveau (obstacles, items et champignon)
*
* @return List des entités
*/
public List<LevelElement> getEntities() {
List<LevelElement> entities = new ArrayList<>();
for (LevelElement e : this.obstacles) {
entities.add(e);
}
for (LevelElement e : this.items) {
entities.add(e);
}
entities.add(victoryMushroom);
return entities;
}
}