Saturday, September 17, 2016

javascript - Updating bots/AI behavior after a fixed elapsed timestamp in game loop?


I am developing a HTML5 game in javascript. Now I have created a few bots and they should be able to change their orientation after a few seconds/a fixed timestamp in the game loop.


Suppose my game loop is like this:


function loop() {
bots.updateOrientation();

bots.render();
player.update();
player.render();
requestAnimationFrame(loop);
}

How can I make that happen in my game loop?




No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...