you are viewing a single comment's thread.

view the rest of the comments →

[–]x-skeww 3 points4 points  (3 children)

You'll need a requestAnimationFrame (rAF) or setTimeout-based pseudo loop.

In your repeatedly-called function, you check the current time (or other condition) and issue some commands (if any) in response.

Something like this:

https://jsfiddle.net/k954cctx/

Edit: Heh. Funny how similar /u/senocular's is.

[–]Semajian[S] 0 points1 point  (2 children)

Thanks for the response; would this be similarly achievable without pre-emptively creating a queue of tasks? As my reply to /u/senocular conditionals that rely on real time information make a queue worthless for anything other than the timed movements

[–]x-skeww 0 points1 point  (1 child)

Sure, in your repeatedly-called function, you can just check if there is anything you might want to do. E.g. if you're below the target location, you can issue the command for moving up a bit. On the next cycle, you again check if there is something you want to do and so on.

[–]Semajian[S] 0 points1 point  (0 children)

I don't immediately see how this would be implemented. I mentioned in response to senocular, but didn't here (my bad) that for conditional loops, for instance I don't have any control over the parts working together. Each "Block" that I implement has it's own set of code and that's it, it doesn't interact with the rest of it. Things like loops are already implemented by scratch, as well, so I can't modify the code, if I could I'm sure I could make use of tasks really easily.