-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnit.java
More file actions
25 lines (21 loc) · 788 Bytes
/
Unit.java
File metadata and controls
25 lines (21 loc) · 788 Bytes
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
import java.util.*;
class Unit {
boolean dead = false;
double x, y;
double w, h;
Unit(double x,double y,double w,double h) {
this.x = x;
this.y = y;
this.w = w;
this.h = h;
}
boolean collides(Unit u) {
return (((x + w) >= (u.x)) && ((x) <= (u.x + u.w)) && ((y + h) >= (u.y)) && ((y) <= (u.y + u.h)));
}
boolean contains(Unit u) {
/*if (((x + w) >= (u.x)) && ((x) <= (u.x + u.w))) {//&& !(((y) <= (u.y)) && ((y + h) >= (u.y + u.h)))) {
System.err.println("Gap = ("+x+","+y+","+w+","+h+") Bird = ("+u.x+","+u.y+","+u.w+","+u.h+")");
}*/
return (((x + w) >= (u.x)) && ((x) <= (u.x + u.w)) && !(((y) <= (u.y)) && ((y + h) >= (u.y + u.h))));
}
}