This site requires JavaScript, please enable it in your browser!
Greenfoot back

Super_Hippo's collections

This user has no collections

Recent Comments | Show All

I think the problem is that the calculated route is not something which can be pre-calculated because the target is unknown before it was chosen and the unit should instantly move after the target was chosen. And since this doesn't even work with one unit, what would happen if there are a lot more trying to move around? I guess either Java is not efficient, my code is not optimal or my computer is too slow.
Increasing the simulation speed won't change anything about the lag. The calculation of one act cycle is always at maximal speed. When it is not at speed = 100, it has a defined delay between the beginnings of the act cycles though. So if I increase the speed, the operations can't be executed faster. I am in fact not understanding what this code is doing. What I am doing is that whenever a new target for a unit is chosen (like moving a unit or unit automatically walks back to nearest town center / storage pit after collecting 10 wood from a tree), it calculates the route once. Then it will walk this route without calculating (unless the route gets blocked by a new building). If it would help, I could post the code used for the route calculation in a new discussion. If I get this right, I can't use this Timer class because the code is not executed once in a while but always when a unit gets a new target.