0

Logically, whats going on in this code, and what are the biggest errors/bad habits in the full code posted?

function loop() { draw(); update(); raf = requestAnimationFrame(draw); } Ive defined the draw & update functions but Im trying to figure out what this does. im assuming that the arg in the [raf] fn is a callback right? So when the code gets to the raf(draw) it will loop back to the draw() func right? What if i were to change elements outside of this main block would the script revert back once it loops? And one more: Should I be nesting the functions or keeping separate? Ill attach the code Im working on too, so If anyone wants to give me notes id be more than appreciated! https://code.sololearn.com/W8RHfx7gy37V/?ref=app

2nd Jun 2022, 11:59 PM
pHANTOM|sTEELE
7 Respuestas
0
pHANTOM|sTEELE Did you create this or just copied online? It looks like it's for animation, changing color and changing position.
3rd Jun 2022, 3:33 AM
Jonathan P. Jundarino
Jonathan P. Jundarino - avatar
0
Did you copied this online and already edited by you?
3rd Jun 2022, 3:33 AM
Jonathan P. Jundarino
Jonathan P. Jundarino - avatar
0
No I am writing myself, I look online for inspiration but then I usually get swallowed down the rabbit hole of e Js errors. What I am working on now is a complete DOM nightmare...
3rd Jun 2022, 3:35 AM
pHANTOM|sTEELE
0
Here's what it looks like now: it's a Dom's all messed up. https://code.sololearn.com/WPDKxX7unVEe/?ref=app
3rd Jun 2022, 3:37 AM
pHANTOM|sTEELE
0
I'm sorry, I can't understand, so https://code.sololearn.com/WPDKxX7unVEe/?ref=app is your inspiration? Or you also make this, if this is the continuation of code that is in your question, then it's finished I guess?
3rd Jun 2022, 3:54 AM
Jonathan P. Jundarino
Jonathan P. Jundarino - avatar
0
No I made this myself.
3rd Jun 2022, 3:55 AM
pHANTOM|sTEELE
0
Hello i'm GHETTO PHILOSOPHER new and i need help i mean guidance please
4th Jun 2022, 11:18 PM
Ahmad Haruna Ahmad
Ahmad Haruna Ahmad - avatar