public Game() {
gameState = OVERWORLD;
objects = new ArrayList<GameObject>();
remove = new ArrayList<GameObject>();
battleObjects = new ArrayList<GameObject>();
battleRemove = new ArrayList<GameObject>();
player = new Player(Display.getWidth() / 2 - player.SIZE / 2, Display.getHeight() / 2 - player.SIZE / 2);
objects.add(player);
objects.add(new Circle(32, 32, player));
objects.add(new Imp(300, 100, player));
}
public void update() {
if (gameState == BATTLE) {
for (GameObject i : battleObjects) {
if (!i.isRemoved())
i.update();
else
battleRemove.add(i);
}
}
else {
for (GameObject i : objects) {
if (!i.isRemoved())
i.update();
else
remove.add(i);
}
}
}
public void render() {
if (gameState == BATTLE) {
for (GameObject i : battleObjects)
i.render();
}
else {
for (GameObject i : objects)
i.render();
}
}
public static void createNewBattle(Player p, Monster m) {
battleObjects.add(p);
battleObjects.add(m);
gameState = BATTLE;
}
I completely understand why its happening but I cannot for the life of me find a way to fix the problem... Can anyone help me??? I sat here for hours trying to find another way of doing this. I was think of just creating an array with the battle objects.