darozak / Advolition

1 stars 0 forks source link

Pause the game engine after every movement cycle #20

Closed darozak closed 7 months ago

darozak commented 7 months ago

I need to pause the game engine after every move cycle so that it's possible to watch the robot move across the arena. I'll doing this by syncing the engine with the system clock.

darozak commented 7 months ago

It took me forever to figure out how to get the canvas to refresh and redraw the arena as the robot moves from one tile to the next. For some reason, the canvas wouldn't refresh until the main.js script ended. I was finally able to fix this by using setInterval()to periodically call the game.run() function in the main.js file. The same procedure doesn't appear to work when called from within the game object itself. Also, I took the while loop out of the run method so now it relies on setInterval() to iteratively evaluate the robots and plot the new scene. Appears to be working well now! (https://github.com/darozak/Advolition/commit/06af96cc0f49a2d75a5cfc0b9f57c3abd350d62c)