Hello my name is Ryan and I'm currently developing my own 2D java game. Currently there are a lot of objects within the game world. Upon a new start of the game, the world loads with 100 tress randomly positioned on it, made with the use of an arraylist and a tree class. My game uses a class called checkcollisions
to check if the player is intersecting with any tress. This method is then put within the update
method. When this method is not called I get an extra 100 FPS is there away I can still get this 100 fps but still check for collisions? I really need an FPS boost asas my game currently runs at 30-50 fps
here is the checkcollisions code:
public void checkCollisions() {
for (int i = 0; i < Placing_Objects.Small_Trees.size(); i++) {
if (player.getBounds().intersects(Placing_Objects.getSmall_Tree().get(i).getBounds())) {
if (gotAxeOn) {Placing_Objects.Small_Trees.get(i).health -= rand.nextInt(3);}
}
if (Placing_Objects.Small_Trees.get(i).health <= 0) {
Placing_Objects.removeSmall_Tree(Placing_Objects.Small_Trees.get(i));
Inventory.addItemToInv("Wood");
Inventory.addItemToInv("Wood");
Inventory.addItemToInv("Stick");
Player.exp += rand.nextInt(3);
challenges.choppedDownTrees += 1;
}
}
}