-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathObstacle.pde
34 lines (28 loc) · 925 Bytes
/
Obstacle.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
public class Obstacle {
public static final int SIZE = 6;
final int damage = 10; // how much damage this obstacle deals
PVector position;
public Obstacle(PVector pos) {
position = pos.copy();
}
public Obstacle(float x, float y) {
position = new PVector(x, y);
}
public boolean collidesWith(PVector other, float size) {
return dist(position.x, position.y, other.x, other.y) < size / 2 + SIZE / 2;
}
public int getDamage() {
return this.damage;
}
public void draw() {
fill(#f4424b);
stroke(#f4424b);
circle(position.x, position.y, SIZE);
int d = 4;
int p = 5;
line(position.x - d, position.y - d, position.x + d, position.y + d);
line(position.x - d, position.y + d, position.x + d, position.y - d);
line(position.x, position.y - p, position.x, position.y + 5);
line(position.x - p, position.y, position.x + p, position.y);
}
}