-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGameObj.java
134 lines (100 loc) · 2.61 KB
/
GameObj.java
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import javafx.scene.paint.Color;
public class GameObj {
private int width, height;
private Vector position, move;
private Color color;
private boolean isVisible;
public GameObj(double x, double y, int width, int height, Color color) {
this.position = new Vector(x, y);
this.width = width;
this.height = height;
this.color = color;
this.move = new Vector(0,0);
this.isVisible = true;
}
public GameObj(double x, double y, int width, int height, int colR, int colG, int colB, double opacity) {
this(x, y, width, height, new Color(colR, colG, colB, opacity));
}
public GameObj(Vector position, int width, int height, int colR, int colG, int colB, double opacity) {
this(position.getX(), position.getY(), width, height, new Color(colR, colG, colB, opacity));
}
public GameObj(Vector position, int width, int height, Color color) {
this(position.getX(), position.getY(), width, height, color);
}
public GameObj(double x, double y, int width, int height) {
this(new Vector(x, y), width, height);
}
public GameObj(Vector position, int width, int height) {
this(position, width, height, new Color(.5, .5, .5, 1));
}
public void setPosition(Vector position) {
this.position = position;
}
public Vector getPosition() {
return position;
}
public void setX(double x) {
position.setX(x);
}
public void setY(double y) {
position.setY(y);
}
public double getX() {
return position.getX();
}
public double getY() {
return position.getY();
}
public void setWidth(int width) {
this.width = width;
}
public void setHeight(int height) {
this.height = height;
}
public int getWidth() {
return width;
}
public int getHeight() {
return height;
}
public void setColor(Color color) {
this.color = color;
}
public void setColor(int red, int green, int blue, double opacity) {
this.color = new Color(red, green, blue, opacity);
}
public void setColor(int red, int green, int blue) {
this.color = new Color(red, green, blue, 1);
}
public Color getColor() {
return color;
}
public int getRed() {
return (int) color.getRed();
}
public int getGreen() {
return (int) color.getGreen();
}
public int getBlue() {
return (int) color.getBlue();
}
public void setMoveVector(Vector moveVector) {
this.move = moveVector;
}
public Vector getMoveVector() {
return move;
}
public void updatePosition() {
this.position.add(move);
}
@Deprecated
public void updatePosition(Vector v) {
this.position.add(v);
}
public void setVisible(boolean visible) {
this.isVisible = visible;
}
public boolean isVisible() {
return isVisible;
}
}