Share your repls and programming experiences

← Back to all posts
Gravity Simulator
MrEconomical (2296)

this is a gravity simulator

I thought it would be cool to be able to mess around with gravity and experiment, so I made this simple gravity simulator.


  • Scientifically accurate (for the most part)
  • Interactive object placement and deletion
  • Customizable gravity values and object masses
  • Tick warping
  • Hotkeys (G for gravity spot, O for object, and X for delete)

A few notes:

The objects do not collide with each other and instead pass through each other, and the gravity spots are fixed (not influenced by gravity)

Simulation might be a bit buggy on very small screens because of how the scaling works but for the most part it's fine

If you zoom out a ton it's laggy

Zavexeon (1162)

Why is everyone better at programming than me lol.

emotionbot (9)

@Zavexeon welcome to the jungle!

arashwales123 (24)

@Zavexeon If it makes it any better im not better than you

arashwales123 (24)

@Zavexeon but my profile pic is an alpaca

DarkswordsmanJG (44)

I am not that good at coding myself

DJWang (1354)

I made a black hole

PowerCoder (740)

If you hold an object to two grey spots you'll get a perfect orbit. (Really nice and satisfying by the way. Great job!)

DJWang (1354)

how do control the number of mass

MrEconomical (2296)

@DJWang open up the settings on the bottom of the toolbar

Dart (1200)

Is this dead yet?


Why don’t you take this to the next level and make a quantum simulator?

PizzaRules668 (9)

You should try to make a 3D version


When I set the gravity to max, I created an orbit where the blue ball goes around in an oval pattern, but then it moves just enough that it creates a spirograph!! Imagine that? Having a year within a year :D

PantheraLeo04 (1)

@JORDANSISNEY Most planets' orbits actually do rotate like how you described.

AtticusKuhn (242)

It is like universe sandbox.

sugarfi (630)

Nice. You should also look into matter.js

FrancisPan (28)

To infinity... AND BEYOND!!!

(it goes on forever)

KobeFF (1269)

@MrEconomical Can I feature this sim on a math&physics website that I am building with other people? Our website is

thenullified (167)

its the most beautiful thing i have ever seen. been looking at this for hours now

awesome10 (232)

so satisfying bro

Andi_Chin (220)

my planet is just gaining infinite energy

UncleSamIs234 (1)

This looks super cool it doesn't look like you used HTML it's just so cool.

WaffleCode (2)

Mine won't load. =[ Probably my AWFUL school connection

sycrepl (10)

yo i just made a binary figure 8 :O

MatthewDoan1 (332)

Nice. Can you add an option to adjust the length of the trail? I want to see the lengths of my comets!