Back to articles
Planetary gravity
How-To

Planetary gravity

via Dev.toNo_Arms_studio

It has been a minute since I last posted a devlog, and this is not it but it is coming soon, I promise. Today I want to talk about my gravity engine using Euler's method of gravity. The first step to this process is to make the planets, I just made a bunch of clones that all drew their position onto the screen with the pen extension. There is also another sprite the size of the screen that refreshes it every tick by stamping it onto the screen. Next I gave each of the planets an initial velocity and mass scaling their size to that mass, you can't see it because the mass of the planets is too close but they are scaled with their mass. The amount that the velocity moves the planets is scaled by the global variable SIZE which also scales the planet size. I have it set to 1000 in this simulation. The result after a few seconds looks like this: After this I setup a function that would make the planets be able to interact with each other's gravity. The way that It works is that each planet h

Continue reading on Dev.to

Opens in a new tab

Read Full Article
3 views

Related Articles