This project has moved and is read-only. For the latest updates, please go here.

2d terrain (worms like)

Sep 3, 2009 at 10:12 PM

Hi Im working on a worms like game using vehicles (just 2d rectangles)

I want to make collision against a bitmap mask that will change (because of explosions) giving the illusion of deformable terrain

Is this possible to do using farseer??


The examples in the source code didnt showed what I was looking for and I have no idea on how to create the collisions myself


thanks a lot for the help!

Sep 3, 2009 at 10:19 PM

Farseer Physics Engine have the tools you need to create deformable terrain. Inside the Vertices class you have several methods to modify vertices on the fly. You can add and subtract (clip) vertice arrays.

There is a demo in the advanced samples that shows you how to do all that.

Sep 3, 2009 at 11:45 PM

Thanks for the reply

Im kinda lost in here so maybe could you be a little bit more specific please?


Thank you

Sep 3, 2009 at 11:51 PM


Demo7 from the AdvancedSamples (download here) shows you how to union and subtract polygons from each other.

It simply uses Vertices.Subtract() that subtracts two polygon collections from each other.

Sep 3, 2009 at 11:58 PM

oh yeah that one.. Ive seen it

I was looking for how to create a terrain from my bitmap mask and have a poligon (just a rectangle will serve me) collide with it

in the examples Ive seen irregular shapes but they move and react to forces as well, I was thinking of having my terrain static





Sep 4, 2009 at 12:05 AM

You can create a vertice collection from a bitmap using the Vertices.CreatePolygon() method. It is used in Demo3 in the AdvancedSamples.

Once you have your terrain data (as a geom) you can collide stuff with it. To make it not react to forces and impulse, just set Body.IsStatic = true. You use the GeomFactory.Instance.CreateRectangle() method to create a rectangle. After you positioned the rectangle, it should collide with the terrain. As for the deformable terrain; When your player fires a weapon, simply create a circle that will represent the explosion, place it on the terrain and subtract the two vertice collections. You will have to remove the old terrain and add a new one. Unless you use SAT as narrow phase, then you can edit the terrain on the fly.

Sep 4, 2009 at 12:17 AM

Is that it?? its so easy!!

oh boy I cant believe it..


One last question: say I only want to use the collision detection part of the library, because Im making a non-realistic game so I dont need friction , earth like gravity,  mass etc etc, just the collision part (well maybe I WILL need gravity but proably it will end being an arbitrary value just to suit my needs)

How can I approach this problem? any recommendations?

Thank you so much !!


Sep 4, 2009 at 11:16 AM

If you want your player to stand on the ground instead of just falling though it, I would suggest you use the physics part too ;)

If you don't need friction, just set it to 0. If you don't need drag, just set it to 0. It is that easy.

Some places you might just want the collision detection. Just create a geometry as you always do, but set Geom.CollisionResponse to false. It will still fire the OnCollision delegate, but it will not react to its surroundings - only detect them.