Repository navigation
Expand file tree
/
Copy pathHandler.java
More file actions
62 lines (51 loc) · 1.67 KB
/
Copy pathHandler.java
File metadata and controls
62 lines (51 loc) · 1.67 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
58
59
60
61
62
package game;
import java.awt.Graphics;
import java.util.LinkedList;
public class Handler {
LinkedList<GameObject> object = new LinkedList<GameObject>();
public void tick() {
for(int i = 0; i < object.size(); i++) {
GameObject tempObject = object.get(i);
tempObject.tick();
//accountForCollision();
}
}
// private void accountForCollision() {
// for (int i = 0; i < object.size(); i++) {
// GameObject tempObject = object.get(i);
// if (object.getId() == ID.Player) {
// for (GameObject tempObj : object) {
// if (tempObj.collidedWith(obj)) {
// //tempObj.accountForCollision(obj);
// if (tempObj.getId() == ID.LightEnemy) {
// object.remove(tempObj);
// }
// }
// else {
// // DO NOTHING
// }
// }
// }
// }
// }
public void render(Graphics g) {
for (GameObject obj : object) {
obj.render(g);
}
}
public void clearEnemy() {
for (int i = 0; i < object.size(); i++) {
GameObject tempObject = object.get(i);
if(tempObject.getId() == ID.Player){
object.clear();
addObject(new Player(ID.Player, tempObject.getX(), tempObject.getY(), this));
}
}
}
public void addObject(GameObject obj) {
object.add(obj);
}
public void removeObject(GameObject obj) {
object.remove(obj);
}
}