I have this game:
http://www.javagaming.org/topics/iconified/26136/view.html..and it seems to clog up the FPS, once I make the map bigger, but worst is it when I begin to use pathfinding with just six entities.
Problem is, I dont know exactly where it happens. It could be my heuristic, it could be too many pathfinding checks  I cant tell.
Is there a way to check what code executes slower/where in the code there might be a bottleneck?
Also, I know my getNearestNeighbor function sucks, and takes like 4 times more heuristic calls than it needs to.
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
 public Path nearestNeighbor(Mover mover, int sx, int sy, int tx, int ty) { Path closest = null; int stepAmount = Integer.MAX_VALUE; for (int x=1;x<2;x++) { for (int y=1;y<2;y++) { if ((x == 0) && (y == 0)) { continue; }
if ((x != 0) && (y != 0)) { continue; } int xp = x + tx; int yp = y + ty; if (isValidLocation(mover, sx, sy, xp, yp)) { Path path = findPath(mover, sx, sy, xp, yp); if (path != null) { int steps = path.getLength(); if (steps < stepAmount) { closest = findPath(mover, sx, sy, xp, yp); stepAmount = steps; } } } } } if (closest != null) { return closest; } else { return null; } }

I'm rendering a lot of images too, from a lot of different sheets. Should I pack them all on one sheet, so I can call drawEmbedded in Slick?
Does that matter a lot at all? When I look at my map, I only get 45 fps/60 fps.
Should I use multithreading for this heavy logic? Help!
I can upload source if you want to check yourself
This was my old heuristic:
1 2 3 4
 float dx = tx  x; float dy = ty  y; float result = (float) (Math.sqrt((dx*dx)+(dy*dy))); 
..and I cant notice the difference with this one:
1 2 3
 float dx = Math.abs(tx  x); float dy = Math.abs(ty  y); float result = dx+dy; 