Canvas and setTimeout & setInterval Functions
Say I have an object with a function. Inside of this function, I want to have a timed effect. In my animation loop, I will be calling this function every frame of animation. For whatever reason, I can't get it to work right with what I want. I'll attach the actual code I'm using it in as well. I'll also attach the one I'm using to get around it. I have boolean flags that control which function the object is using at any point (harvesting, returning home, or going to resource point). When the timeout happens, I want the flags to switch after the harvester has taken minerals. It's just taking all of the minerals available and not switching the booleans. Am I doing something stupid in javascript that I don't know about?? Working Code: https://code.sololearn.com/WwfE1I1vvyxA What I want, but broken: https://code.sololearn.com/WRnfxulb96Z0 The issue is in the this.harvest function in the harvester 'object'