-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameObject.java
More file actions
46 lines (38 loc) · 786 Bytes
/
Copy pathGameObject.java
File metadata and controls
46 lines (38 loc) · 786 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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
public class GameObject {
private double x;
private double y;
private int width;
private int height;
private String image;
public GameObject(double x, double y, int width, int height, String image) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.image = image;
}
public void draw() {
double screenX = x + width/2;
double screenY = y + height/2;
StdDraw.picture(screenX, screenY, image, width, height);
}
public double getX() {
return this.x;
}
public double getY() {
return this.y;
}
public void move(double x, double y) {
this.x = x;
this.y = y;
}
public int getWidth() {
return this.width;
}
public int getHeight() {
return this.height;
}
public void setImage (String image) {
this.image = image;
}
}