-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameObject.java
More file actions
57 lines (52 loc) · 1.26 KB
/
GameObject.java
File metadata and controls
57 lines (52 loc) · 1.26 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
import java.awt.geom.*;
import java.awt.*;
/*
* GameObject that encircle any game objects will hitboxes
*/
public abstract class GameObject{
double x;
double y;
int width;
int height;
Rectangle2D hitbox;
GameObject(){
this.hitbox = new Rectangle((int)this.x, (int)this.y, this.width, this.height);
}
public int getX(){
return (int)this.x;
}
public int getY(){
return (int)this.y;
}
public double getDoubleY(){
return this.y;
}
public double getDoubleX(){
return this.x;
}
public int getWidth(){
return this.width;
}
public int getHeight(){
return this.height;
}
public Rectangle2D getHitBox(){
return this.hitbox;
}
public void setX(double x){
this.x = x;
this.hitbox.setRect(x, this.y, this.width, this.height);
}
public void setY(double y){
this.y = y;
this.hitbox.setRect(this.x, y, this.width, this.height);
}
public void setWidth(int width){
this.width = width;
this.hitbox.setRect(this.x, this.y, width, this.height);
}
public void setHeight(int height){
this.height = height;
this.hitbox.setRect(this.x, this.y, this.width, height);
}
}