I'm currently watching tutorials to build projects as I'm still not in a phase where I can carve a project that I want all on my own.
Currently, working on a snake game.
My confusion:
What happens when return is executed in this code? According to chatGPT, the function terminates. I get that. But does that mean it won't be called again via "Main logic starts here" part?
Currently, working on a snake game.
Code:
let speed = 2; let lastPaintTime = 0; //Game functions function main(ctime) { window.requestAnimationFrame(main); if ((ctime - lastPaintTime) / 1000 < 1 / speed) { return; } lastPaintTime = ctime; gameEngine(); } //Main logic starts here window.requestAnimationFrame(main);
What happens when return is executed in this code? According to chatGPT, the function terminates. I get that. But does that mean it won't be called again via "Main logic starts here" part?
Comment