-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpieler.pde
More file actions
54 lines (40 loc) · 1.01 KB
/
Spieler.pde
File metadata and controls
54 lines (40 loc) · 1.01 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
public class Spieler {
Vec pos = new Vec();
Vec vel = new Vec();
float durchmesser;
float schnell;
int punkte;
Spieler(float x, float y, float durch, float schneller, int punk) {
pos.x = x;
pos.y = y;
durchmesser = durch;
schnell = schneller;
punkte = punk;
}
public void beschleunigen(Vec dreh) {
vel.x = dreh.y * schnell;
vel.y = dreh.x * schnell;
}
public void update(float dt) {
pos.x += vel.x * dt;
if(pos.x - durchmesser / 2 <= 0) {
pos.x = durchmesser / 2;
}
if(pos.x + durchmesser / 2 >= width) {
pos.x = width - durchmesser/2;
}
pos.y += vel.y * dt;
if(pos.y - durchmesser / 2 <= 0) {
pos.y = durchmesser / 2;
}
if(pos.y + durchmesser / 2 >= height) {
pos.y = height - durchmesser / 2;
}
}
public void show() {
fill(255,153,51);
strokeWeight(2.0);
stroke(112, 112, 112);
ellipse(pos.x, pos.y, durchmesser, durchmesser);
}
}