This topic is for a collab/discussion on how to make a solar system or moon system on hopscotch. Anyone is allowed to join. Just reply to this topic asking to be added.
Planetary gravity pls help
Well, first you can get your planet.
Get a circle and make it gray, add holes, etc.
Then, make your sun.
Make the circle/planet move in an circle/elipse , turning invisible when it touches the sun.
Like this
Game starts
Set Variable to 0
(Repeat forever= Move forward 1, turn one)
When Planet is touching Sun
Set invisibility 100%
Set Varible to 1
Game starts
(Check once if Variable=1
Set invisibility 0)
What I â€śCodedâ€ť above makes the planet move in a circle, making so it looks like itâ€™s rotating.
I could code you on my alt account if you want!
@CoderOfMagic, I was thinking of having gravity, so it is as realistic/accurate as possible, not just a circle around it
Not to offend, just to clarify
Okay! Maybe then do a eclipse instead of a circle, with a tilted axis! You could also add that the planet curves around the end of the eclipse!
I donâ€™t think you are getting what I am saying
I want to do the orbit mathematicly, not preprogramed static orbit
Yes something like thatâ€¦ I found an accurate simulation on the internet, but I canâ€™t find what equation/algorithm they used. IDK the exact link, but if you want to look, Google â€śPHET planet orbit simâ€ť
You find an equation for planet gravityâ€¦
g=G*r^2
Where g is gravity
G is gravitational constant (6.6^11)
r is radius
Youâ€™re close

The force then needs to be resolved into X and Y components
 Calculate the angle between the 2 masses
 Use trig to calculate X & Y components

Acceleration (X & Y) of each body can calculated with Newtonâ€™s 2nd Law of Motion: F=ma

Velocity (X & Y) can be calculated using the 1st equation of motion: Vf = V0 + at
 V0 is the initial velocity
 Vf is the final velocity
 The final velocity of one frame becomes the initial velocity of the next
 1 frame in Hopscotch is 16.7ms (.0167s) when executing without lag

and finally, velocity can equate to how many pixels the masses move per frame in your project
If you mean how to implement it, itâ€™s just
Set Position
x [(self)â€™X Positionâ€™ + X_velocity]
y [(self)â€™Y Positionâ€™ + Y_velocity]
Would you like me to credit you? I would like to if thatâ€™s ok with you @ThinBuffalo
Thatâ€™s entirely up to you. If you made a project you think is cool, and maybe learned something along the way, then Iâ€™m happy
@ThinBuffalo, I got this far, but it still has problemsâ€¦ these are some equations that I used:
Here is the link to the project:
https://c.gethopscotch.com/p/zx2rpl762
And what it does: