DEV Community

Emilio
Emilio

Posted on • Updated on

do you guys like the javascript code

https://codepen.io/etwas-deutsch/pen/MWZdjBo?editors=1000

here is the updated version

Top comments (6)

Collapse
 
cdoubleutj profile image
Cdoubleutj

Yeah, I like it. But you could improve it by using requestAnimationFrame instead of setInterval because it is much more precise and even handles frame drops. That way it will look smoother.

Grüße aus Rostock ;)

Collapse
 
emilio-lizarraga profile image
Emilio

thank you i will code that in a bit

Collapse
 
emilio-lizarraga profile image
Emilio

so i just going to get rid of the javascript and just make it an HTML so ja that's going to happen

Thread Thread
 
emilio-lizarraga profile image
Emilio

also um any other suggestions

Thread Thread
 
cdoubleutj profile image
Cdoubleutj • Edited

I think another cool thing would be to attach something like a moon to the planet that is orbiting the sun and let that moon orbit the planet. That way it will look like a planetary system. You could achieve this by creating position objects that hold x and y values and reference the position object of planet as anchor in moon. Because objects in javascript are passed by reference, you can then change the position of planet each frame (wich also changes the moon anchor because it is referencing the same object)

Take a look at this jsfiddle i made :)
Orbit Demo

Thread Thread
 
emilio-lizarraga profile image
Emilio

That is a good idea also the is really cool