Can Box2D be used for Gravity games

  ... the Physics Box2D Extension for AndEngine.

Can Box2D be used for Gravity games

Postby ivascaflavius » Wed May 02, 2012 1:00 pm

Hi there,

I have used AndEngine for a simple game that did not require the use of physics, so I am not very familiar with Box2D extension.

My question is if Box2D could be used to simulate objects that have their own gravitational field and can influence other (smaller) objects (which would orbit around them, get deflected / sling shot, or crash into to the surface). This would be similar to the interactions between planets, moons and asteroids in space. :lightning:

As an example see Angry Birds Space, where the birds get caught in the gravitation field of the planet, orbit around within the atmosphere and then descend to the surface, in their attempt to hit the target.

Do you think something similar could be possible with Box2D? :?:

Thanks.
Last edited by ivascaflavius on Fri May 04, 2012 10:53 am, edited 1 time in total.
ivascaflavius
 
Posts: 17
Joined: Sat Mar 31, 2012 11:19 pm
Location: Timisoara, Romania

Re: Can Box2D be use for Gravity games

Postby Primadawn » Thu May 03, 2012 12:55 am

It can be used for gravity games but I don't think it supports a planetary gravity concept.
However, it shouldn't be to hard to implement. (depending of course on the complexity of the system you want to build)
What I would do is work with zero gravity, create sensors around the planets/asteroids and when an object hits that sensor start applying force on it towards the centre of the planet/asteroid. You'll have to keep applying force on all objects within the sensor on every update.
Primadawn
 
Posts: 414
Joined: Fri Sep 23, 2011 3:28 am

Re: Can Box2D be use for Gravity games

Postby ivascaflavius » Thu May 03, 2012 9:23 am

Thanks for the reply.
This is starting to make more sense now. :lighbulb:

As for the idea I had in mind, it should not be very complex. Originally I thought it wasn't already made into a game but I was wrong. I guess with half a million apps, just about everything has been done already.
My initial game idea was very similar to this existing app: link.
ivascaflavius
 
Posts: 17
Joined: Sat Mar 31, 2012 11:19 pm
Location: Timisoara, Romania

Re: Can Box2D be used for Gravity games

Postby Choba » Wed May 09, 2012 4:19 pm

There is a PointGravityPhysicsWorld created by Jacoby6000 which works that way! You can add multiple massive bodies that have their own gravity depending on their size/mass. ;)

post29174.html?hilit=point%20gravity#p29174
Choba
 
Posts: 12
Joined: Wed May 09, 2012 4:05 pm

Re: Can Box2D be used for Gravity games

Postby ivascaflavius » Thu May 10, 2012 10:23 am

Great,

Thanks, I'll be sure to take a look whenever I will have the time to work on that potential game.
ivascaflavius
 
Posts: 17
Joined: Sat Mar 31, 2012 11:19 pm
Location: Timisoara, Romania


Return to Physics Box2D

Who is online

Users browsing this forum: RonScript, s and 8 guests