I’m developing a simple simulation involving city budgeting for local officials to use. I have developed a map for the simulation and an algorithm that ‘grows’ the map when its function is called. Thus, updateMap(); results in numerous changes across the field of play. Currently, I have this function bound to other mechanisms in the game, called once every time something else happens, for example. My question is this: is there any way to have something like this
while (true)
setTimeout('updateMap();', 45000);
such that the map will update itself independently of whatever the user is doing and whatever is going on in the game. I understand that Javascript doesn’t support threading, but is there any to simulate some simple thread that would act like this?
You would be looking for
setInterval(updateMap, 45000)It will take the function you give it and run it every x milliseconds.
Hope this helps!