https://www.youtube.com/watch?v=Rxj0HNX ... e=youtu.be
So yeah. Balls with gravity.
Gravity Balls!
Re: Gravity Balls!
its quite something
why wont you share the code >:C
why wont you share the code >:C
Re: Gravity Balls!
I might later, if I get some more things done like, cleaner code, camera module, and a stable orbit :p
Example of "bad" code:
Example of "bad" code:
Code: Select all
function planet.update(dt)
for i, v in ipairs(planetMap) do
local dist = math.sqrt((v.xPos - player.xPos)^2 + (v.yPos - player.yPos)^2)
if dist <= v.inf + 4 then
v.isColliding = true
local angle = math.atan2((v.yPos - player.yPos), (v.xPos - player.xPos))
player.addVel((v.gravity*(v.inf*0.01)*math.cos(angle)), (v.gravity*(v.inf*0.01))*math.sin(angle), dt)
else
v.isColliding = false
end
for i, f in ipairs(planetMap) do
if v ~= f then
local dist = math.sqrt((v.xPos - f.xPos)^2 + (v.yPos - f.yPos)^2)
if dist <= v.inf + f.inf then
local angle = math.atan2((v.yPos - f.yPos), (v.xPos - f.xPos))
planet.addVel(f, (v.gravity*(v.inf*0.01)*math.cos(angle)), (v.gravity*(v.inf*0.01))*math.sin(angle), dt)
end
end
end
planet.move(v, dt)
end
end
Re: Gravity Balls!
I made something similar a while back. The gravity calculation is a dirty implementation of Newton's law of universal gravitation. Collision is handled by love.physics.
You can spawn objects with the mouse, Right click for static, left click for dynamic.
With dynamic objects you can also click and drag to spawn them with some velocity.
Code could be cleaner. There's probably mad bugs. Look at the source at your own risk.
You can spawn objects with the mouse, Right click for static, left click for dynamic.
With dynamic objects you can also click and drag to spawn them with some velocity.
Code could be cleaner. There's probably mad bugs. Look at the source at your own risk.
- Attachments
-
- Planet Physix.love
- (81.2 KiB) Downloaded 122 times
- HugoBDesigner
- Party member
- Posts: 403
- Joined: Mon Feb 24, 2014 6:54 pm
- Location: Above the Pocket Dimension
- Contact:
Re: Gravity Balls!
Nice little concept! I also made something similar a while ago (you can still find it HERE), but yours seems a lot more "professional" than mine (mine was just a random doodle, but still).
Am I the ONLY one who thought it was a pun about Gravity Falls?
Am I the ONLY one who thought it was a pun about Gravity Falls?
Re: Gravity Balls!
Actually, that is correct! xDHugoBDesigner wrote:Nice little concept! I also made something similar a while ago (you can still find it HERE), but yours seems a lot more "professional" than mine (mine was just a random doodle, but still).
Am I the ONLY one who thought it was a pun about Gravity Falls?
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Gravity Balls!
Didn't think it was a pun, but I was confused for a bit.HugoBDesigner wrote:Am I the ONLY one who thought it was a pun about Gravity Falls?
Help us help you: attach a .love.
Re: Gravity Balls!
I recoded some stuff, made things neater, removed the player completely (Because it was basically a "ball" with no gravity) and added 3 cool things.
1. Ooooh snap, collision detection and resolving... somewhat.
It's very basic, and not good, and it even has a bug which is now a feature, and that is...
2. ...MERGING PLANETS!
Oooooooh snap.
Planets can now merge together because of their gravity and create a planet with triple or quadruple of infinitly its gravity. Dayum
3. Oh, and some lines between planets which are in their spheres of influences. meh.
Also, binary orbits! Whoo
https://www.youtube.com/watch?v=LGnyJyt ... e=youtu.be
1. Ooooh snap, collision detection and resolving... somewhat.
It's very basic, and not good, and it even has a bug which is now a feature, and that is...
2. ...MERGING PLANETS!
Oooooooh snap.
Planets can now merge together because of their gravity and create a planet with triple or quadruple of infinitly its gravity. Dayum
3. Oh, and some lines between planets which are in their spheres of influences. meh.
Also, binary orbits! Whoo
https://www.youtube.com/watch?v=LGnyJyt ... e=youtu.be
Who is online
Users browsing this forum: No registered users and 4 guests