-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHandler.java
More file actions
55 lines (42 loc) · 1.12 KB
/
Handler.java
File metadata and controls
55 lines (42 loc) · 1.12 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
package com.tutorial.main;
import java.awt.Graphics;
import java.util.LinkedList;
public class Handler {
private boolean clearing = false;
LinkedList<GameObject> object = new LinkedList<GameObject>();
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++) {
if (clearing) {
return;
}
GameObject tempObject = object.get(i);
tempObject.render(g);
}
}
public void clearEnemies() {
clearing = true;
for (int i = 0; i < object.size(); i++) {
GameObject tempObject = object.get(i);
if (tempObject.getId() == ID.Player) {
object.clear();
if (Game.gameState != Game.STATE.End) {
addObject(new Player((int) tempObject.getX(), (int) tempObject.getY(), ID.Player, this));
}
break;
}
}
clearing = false;
}
public void addObject(GameObject object) {
this.object.add(object);
}
public void removeObject(GameObject object) {
this.object.remove(object);
}
}