You are browsing as a guest. Sign up (or log in) to start making projects!

3h 43m 18s logged


The Gravity Grid, Way More Orbits, & Bottom Buttons


What I Added:

I wanted to make the physics actually look cool, so I coded a visible gravity grid that connects the stars. I also upgraded the code to support multiple orbits at the same time and added a bottom control toolbar so you don’t have to reload the page to change settings.


How I Coded It:


The Spacetime Grid:

I wrote a function that loops through rows on the canvas. For every single point, it checks how far away it is from each star and calculates a vector to pull the grid line closer to the mass. It looks sick because the lines warp around the stars.


Upgraded Physics:

I rewrote the integration loop so it can handle a ton of planets and multiple stars all pulling on each other at once. It figures out which star has the strongest gravitational pull on a planet and tracks its angle around it to reset and handle smooth transitions if it gets yanked away by a bigger star.


Bottom Toolbar:

I put together a HTML/CSS toolbar at the bottom. I coded buttons to toggle the grid on/off and turn on light trails (trailsEnabled) so the planets leave glowing streaks behind them as they fly around.


Up Next:

Music FINALLY!

0
1

Comments 0

No comments yet. Be the first!