-
Notifications
You must be signed in to change notification settings - Fork 0
/
Level1.java
105 lines (90 loc) · 2.83 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
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
94
95
96
97
98
99
100
101
102
103
104
105
/*
* Author: Clément Petit
* Date: 15.10.2015
*/
package ch.epfl.cs107.play.game.actor.bike;
import java.awt.Color;
import ch.epfl.cs107.play.game.actor.ActorGame;
import ch.epfl.cs107.play.game.actor.Level;
import ch.epfl.cs107.play.game.actor.crate.Crate;
import ch.epfl.cs107.play.game.actor.general.Terrain;
import ch.epfl.cs107.play.math.Polyline;
import ch.epfl.cs107.play.math.Transform;
import ch.epfl.cs107.play.math.Vector;
import ch.epfl.cs107.play.window.Canvas;
public class Level1 extends Level{
private Polyline polyline;
private Terrain terrain;
private Crate crate1;
private Crate crate2;
private Crate crate3;
private Bike bike;
private Finish finish;
private Checkpoint cp;
private Vector bikePos = new Vector (4.0f, 5.0f);
private Vector cpPos = new Vector (-10.0f, 0.0f);
public Level1(ActorGame game) {
super(game);
}
public void createAllActors(boolean checkpoint) {
final float crateWidth = 1.0f;
final float crateHeight = 1.0f;
if (checkpoint) {bikePos = cpPos;
}
polyline = new Polyline(
-1000.0f, -1000.0f,
-1000.0f, 0.0f,
0.0f, 0.0f,
3.0f, 1.0f,
8.0f, 1.0f,
15.0f, 3.0f,
16.0f, 3.0f,
25.0f, 0.0f,
35.0f, -5.0f,
50.0f, -5.0f,
55.0f, -4.0f,
65.0f, 0.0f,
6500.0f, -1000.0f
);
terrain = new Terrain(getActorGame(), polyline, Color.GRAY, Color.green, 1.0f);
crate1 = new Crate(getActorGame(), false, new Vector(0.0f, 5.0f), "box.4.png", crateWidth, crateHeight, 1.0f);
crate2 = new Crate(getActorGame(), false, new Vector(0.2f, 7.0f), "box.4.png", crateWidth, crateHeight, 1.0f);
crate3 = new Crate(getActorGame(), false, new Vector(2.0f, 6.0f), "box.4.png", crateWidth, crateHeight, 1.0f);
bike = new Bike(getActorGame(), false, bikePos);
finish = new Finish(getActorGame(), new Vector(45.0f, -5.0f));
cp = new Checkpoint(getActorGame(), cpPos);
getActorGame().setViewCandidates(bike);
}
@Override
public Finish getFinish() {
return finish;
}
@Override
public Bike getBike() {
return bike;
}
@Override
public Checkpoint getCp() {
return cp;
}
@Override
public void draw(Canvas canvas) {
terrain.draw(canvas);
crate1.draw(canvas);
crate2.draw(canvas);
crate3.draw(canvas);
finish.draw(canvas);
}
//la redéfinition de getTransform() et getVelocity() est obligatoire ici comme dans chaque autre level,
//car la classe Level implémente l'interface Actor.
//Cependant elle n'ont pas ici d'utilité, chaque acteur du Level ayant ses propres fonctions.
//Le choix de return terrain.getEntity()... est donc arbitraire et n'a pas d'impact sur le jeu.
@Override
public Transform getTransform() {
return terrain.getEntity().getTransform();
}
@Override
public Vector getVelocity() {
return terrain.getEntity().getVelocity();
}
}