Box2D + Top Down Shooter = Possible ? ...

BlitzMax Forums/Brucey's Modules/Box2D + Top Down Shooter = Possible ? ...

mic_pringle(Posted 2009) [#1]
Hi,

Most of the examples I've seen for Box2D seem to use the library for platformers or just plain physics games such as things falling from the top of the screen, demolition type games etc

But I was wondering if it would be possible to use the library for a top-down shooter such as R-Type ?

If so, how would one go about setting up the physics world to represent this as I think gravity would not come into play the same way as it would for the above examples.

[EDIT]Obviously R-Type isn't a top down shooter, doh! Perhaps 1941 is a better example[EDIT]

Thanks

-Mic


plash(Posted 2009) [#2]
I think the main point in a setup for a top-down shooter would be to turn off gravity.


mic_pringle(Posted 2009) [#3]
@Plash

Are there any adverse side effects to turning off gravity ?

How would forces be applied to the world entities if gravity was turned off ?

Thanks

-Mic


Brucey(Posted 2009) [#4]
By top-down, you mean that you are looking down onto the game?

The only time I'd think physics would be useful here is in some kind of driving game - which alas, Box2D isn't well suited to handling that kind of effect (like that of top-down tyres on a road).

However, if you weren't overly concerned with the whole friction thing, but were doing something like 1941, then I see no reason you couldn't do something with it.
As Plash says, you turn off the gravity (which normally makes things drop)
The physics engine would take care of collisions and such (which you can trap and perform an action on them if you need to).


plash(Posted 2009) [#5]
Are there any adverse side effects to turning off gravity ?
I'm not sure. I just heard that suggestion before. I've never really used either Box2D or Chipmunk very much.

How would forces be applied to the world entities if gravity was turned off ?
Just as you would normally?


mic_pringle(Posted 2009) [#6]
@Brucey

Yeah I mean as though you are looking down onto the game - birds eye view.

I'm not overly concerned with friction, it is more collisions and raycasting that I am interested in ... but I would also like to use pulleys, gears and chains.

Thanks

-Mic


Brucey(Posted 2009) [#7]
Yeah, turn off gravity and things will just "float" around (obviously not randomly, but based on all those nice things like force, velocity and angular velocity).

Something like asteroids comes to mind, I suppose - which is, in effect, top-down.


mic_pringle(Posted 2009) [#8]
@Brucey

Cool!

So to turn off gravity, do you just set your vector to zero when you create your world or is there some other gravity flag to set ?

Thanks

-Mic


Brucey(Posted 2009) [#9]
There's a global gravity vector. If you set it to 0,0 there'll be no gravity :-)


_Skully(Posted 2009) [#10]
What is better / more complete? Box2D or Farseer?


_Skully(Posted 2009) [#11]
I'm hearing (from elsewhere) that Box2D is quite fast compared to Farseer... I'll have to try it.


Brucey(Posted 2009) [#12]
Alas, I've no experience of Farseer. Only Box2D and Chipmunk. Both of which seem relatively fast.

Box2D is currently being rewritten - in a effort to make it even faster. But I've not started work on that port yet - I'll likely do it as a completely new module, given the amount of changes/differences.


_Skully(Posted 2009) [#13]
What are the challenges going to be adding tile collisions to a physics system? Thats what I have been fighting with for the last couple weeks and it just wasn't cooperating.


Armitage 1982(Posted 2009) [#14]
About the top down physics, the roadmap of Box2d will cover this feature in future version.
But for the moment you have to turn off gravity and add yourself every forces like friction/gravity/angular/etc. to every dynamic object.
This also give you a better control on your objects. I don't recommend using the gravity option in most cases.

It's certainly possible to create nice top down game with the current version of Box2d but it will require a bit more of work.

The Farseer mod is fully ported in BlitzMax so probably easier to tweak but certainly slower than Box2d.
It really depend of how much physics objects you want in your simulation.

In the next version of the edgesChain you will be able with a single edge to create one way surface "a la Super Mario Bros" so it could perfectly fit a collision tile map editor.
Or why not analyse every collision tiles in order to produce a whole polygon form with a reduced number of Edges Chain ?