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.
Yeah, sure! You could tag pomtl for some more people who could be interested.
i can help to
but i’m pretty much useless at coding
I’m not sure how to do this so sorry
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.
Set Variable to 0
(Repeat forever= Move forward 1, turn one)
When Planet is touching Sun
Set invisibility 100%
Set Varible to 1
(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 pre-programed 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…
Where g is gravity
G is gravitational constant (6.6^-11)
r is radius
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
Omg! Thanks you so much! I just can’t figure out how velocity works…
If you mean how to implement it, it’s just
x [(self)’X Position’ + X_velocity]
y [(self)’Y Position’ + Y_velocity]
Ah ok that’s exactly what I needed
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