-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGameObject (1).java
83 lines (61 loc) · 1.7 KB
/
GameObject (1).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
package Game.main;
import java.awt.Graphics;
import java.awt.Rectangle;
import Game.main.ID;
public abstract class GameObject {
protected float x;
protected float y;
protected float velX;
protected float velY;
protected float[] vel;
protected ID id;
public GameObject(float x, float y, ID id){ //CONSTRUCTOR (MAKER)
this.x = x;
this.y = y;
this.id = id;
vel = new float[2];
vel[0] = 0;
vel[1] = 0;
}
public abstract void tick();
public abstract void render(Graphics g);
public abstract void hide(Graphics g);
public abstract void restoreVel();
public abstract Rectangle getBounds();
public void setX(float x){ //MUTATOR (SETTER)
this.x = x;
}
public void setY(float y){ //MUTATOR (SETTER)
this.y = y;
}
public float getX(){ //ACCESSOR (GETTER)
return x;
}
public float getY(){ //ACCESSOR (GETTER)
return y;
}
public void setID(ID id){ //MUTATOR (SETTER)
this.id = id;
}
public ID getID(){ //ACCESSOR (GETTER)
return id;
}
public void setVelX(float velX){ //MUTATOR (SETTER)
this.velX = velX;
}
public void setVelY(int velY){ //MUTATOR (SETTER)
this.velY = velY;
}
public float getVelX(){ //ACCESSOR (GETTER)
return velX;
}
public float getVelY(){ //ACCESSOR (GETTER)
return velY;
}
public void print(){
if(id == ID.Enemy){
System.out.println("Real Time: " + velX + ", " + velY);
System.out.println("Stored: " + vel[0] + ", " + vel[1]);
}
}
}