-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPlayer.pde
More file actions
61 lines (55 loc) · 1.29 KB
/
Player.pde
File metadata and controls
61 lines (55 loc) · 1.29 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
public class PLAYER {
PVector pos = new PVector();
float fv = 0, a = 0.01;
int max = 1;
int v = 5;
int w = 25, h = 25;
int jumps = 3;
int leben = 3;
int streak = 0;
boolean hit = false, alive = true;
boolean right = false;
boolean left = false;
boolean wait = false;
int points = 0;
PLAYER() {
pos.set(width/2 -25, 100);
}
void update() {
bewegung();
collision();
setPoints();
rect(pos.x, pos.y, w, h);
}
void bewegung() {
if(pos.y <= 0) fv = 1;
if(fv < max)fv += a;
pos.y += fv;
if(pos.y>= height/2)fv = -0.1;
//rechts
if (pos.x < width-w && right) pos.x += v;
// links
if (pos.x > 0 && left) pos.x -= v;
}
void collision() {
if (!hit) {
if (pos.x < o.pos.x && pos.y > o.pos.y-h && pos.y < o.pos.y+50 ||pos.x + w > o.pos.x+100 && pos.y > o.pos.y-h && pos.y < o.pos.y+50 ) {
if (leben > 0) leben--;
if (leben <= 0) alive = false;
hit = true;
streak = 0;
bgt = 0;
}
}
}
void setPoints() {
if (pos.y -100 > o.pos.y && !hit && !wait) {
streak ++;
points += streak;
if(streak >= 5)jumps++;
wait =true;
if(streak >= 7)leben++;
wait =true;
}
}
}