Hey guys, I saw a cool gif the other day (friend posted it on FB) and decided to write a simple gravity thing that works across multiple planets.
The math is pretty basic, essentially each planetling grabs the nearest planet and has it's valued modified according to direction and gravity. Slightly different to real life, the gravitational pull gets stronger the further away you are. Pretty C++-ish, with the polymorphism and OO.
Look at the source, learn, modify, make the planetlings bounce off the planet, whatever.
It's fairly quick, on my i5 it can handle about 5000 planetlings before it starts to dip in FPS.
License: http://www.wtfpl.net/
Planets and Gravity
-
- Prole
- Posts: 19
- Joined: Sat Jun 08, 2013 7:27 am
- Location: Melbourne, Australia
Planets and Gravity
- Attachments
-
- gravity_OO.love
- (2.17 KiB) Downloaded 526 times
Last edited by andrew.207 on Wed Oct 30, 2013 9:21 pm, edited 1 time in total.
http://www.atunnecliffe.com/
Bitcoins? 1LHn9yaErCakYD2iGwCyLungiC7ACxRUW8
Bitcoins? 1LHn9yaErCakYD2iGwCyLungiC7ACxRUW8
Re: Planets and Gravity
WHAT! THIS JUST BLOWN MY MIND! good job!
- shatterblast
- Party member
- Posts: 136
- Joined: Tue Dec 11, 2012 9:47 pm
- Location: Dallas, Texas, USA
Re: Planets and Gravity
The concept is pretty awesome and sweet. It's like a simulated orbit I guess.
- Ranguna259
- Party member
- Posts: 911
- Joined: Tue Jun 18, 2013 10:58 pm
- Location: I'm right next to you
Re: Planets and Gravity
Could you try something for me, I don't have time to peek into you code right know, but could you make two objects, each one with 'gravity', and make them 'moveable' ? I want to see if they start orbiting around each other, if not it's time to start improving your code to a whole new gravitational physics level
And if do that you could test your code with the solar system and maybe we could make an atom simulator, that'd be cool
And if do that you could test your code with the solar system and maybe we could make an atom simulator, that'd be cool
-
- Prole
- Posts: 19
- Joined: Sat Jun 08, 2013 7:27 am
- Location: Melbourne, Australia
Re: Planets and Gravity
No worries, here you go. It doesn't run off Newton's gravitational constant, it runs off whatever number you type in. I picked 80,000, not sure why.
Seems to work ok, the only awkward part was setting the initial velocities so they didn't just whack into each other.
Seems to work ok, the only awkward part was setting the initial velocities so they didn't just whack into each other.
- Attachments
-
- Gravity_OO-atom.love
- (2.71 KiB) Downloaded 280 times
http://www.atunnecliffe.com/
Bitcoins? 1LHn9yaErCakYD2iGwCyLungiC7ACxRUW8
Bitcoins? 1LHn9yaErCakYD2iGwCyLungiC7ACxRUW8
Re: Planets and Gravity
You might want to check out Gravity Ghost by Erin Robinson and friends.
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.
- Ranguna259
- Party member
- Posts: 911
- Joined: Tue Jun 18, 2013 10:58 pm
- Location: I'm right next to you
Re: Planets and Gravity
WOW this is just awesome, I'm definitely going to look into you code this weekend
Keep on doing the incredibly awesome work man
Keep on doing the incredibly awesome work man
Who is online
Users browsing this forum: RetroKevin and 0 guests