-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLevel.pde
72 lines (64 loc) · 1.25 KB
/
Level.pde
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
class Level
{
private int startX = width / 4 * 3;
private int startY = height / 2;
private int zielX = 0;
private int zielY = height / 2 - 20;
private ArrayList<Hindernis> hindernisse;
public Level(ArrayList<Hindernis> h)
{
this.hindernisse = h;
}
public void render()
{
stroke(tStrokeColor);
fill(tFillColor);
rect(this.zielX, this.zielY, 10, 40);
//Hindernisse
for(int i = 0; i < hindernisse.size(); i++)
{
Hindernis h = hindernisse.get(i);
h.render();
}
}
public void update()
{
if(cX < zielX + 10 && cX > zielX && cY < zielY + 40 && cY > zielY)
{
win();
}
for(int i = 0; i < hindernisse.size(); i++)
{
Hindernis h = hindernisse.get(i);
if(h.isPointInside(cX, cY))
{
reset();
//fail--;
}
}
if(win > 0)
{
if(cX < zielX)
{
cX = zielX;
}
if(cX > zielX+10)
{
cX = zielX+10;
}
if(cY < zielY)
{
cY = zielY;
}
if(cY > zielY+40)
{
cY = zielY+40;
}
}
}
public void reset()
{
cX = startX;
cY = startY;
}
};