-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHandler.java
68 lines (53 loc) · 1.38 KB
/
Handler.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
package Game.main;
import java.awt.Graphics;
import java.util.LinkedList;
import Enemies.GameObject;
public class Handler {
public LinkedList<GameObject> object = new LinkedList<GameObject>();
private static int countTimesDone = 1;
private void restorVel(){
for(int i = 0; i < object.size(); i++){
GameObject tempObject = object.get(i);
tempObject.restoreVel();
}
}
public void tick(){
for(int i = 0; i < object.size(); i++){
GameObject tempObject = object.get(i);
tempObject.tick();
}
}
public void render(Graphics g){
for(int i = 0; i < object.size(); i++){
GameObject tempObject = object.get(i);
tempObject.render(g);
}
}
public void hide(Graphics g){
for(int i = 0; i < object.size(); i++){
GameObject tempObject = object.get(i);
tempObject.hide(g);
}
}
public void restore(Graphics g){
restorVel();
}
public void addObject(GameObject object){
this.object.add(object);
}
public void removeObject(GameObject object){
this.object.remove(object);
}
public void clearEnemies(){
for(int i = 0; i < object.size(); i++){
GameObject tempObject = object.get(i);
if(tempObject.id == ID.Player){
object.clear();
addObject(new Player(Game.WIDTH/2-30, Game.HEIGHT/2-30, ID.Player, this));
}
}
}
public void clear(){
object.clear();
}
}