Suggestions needed: Landscape - setup and collisions

Topics: Developer Forum
Jun 17, 2008 at 9:25 PM
I'm wanting to do a side-scrolling game which involves creating a landscape of mountains. This will be using Silverlight Beta 2.

Has anyone got any ideas/suggestions on how the best way would be to setup the landscape so that Farseer can handle collision detection against it without slowing the game down by having too many objects?
Jun 18, 2008 at 3:24 AM
It is tough to answer without knowing more.  What you don't want to do is create a bunch of geoms on the fly, better to precreate any geoms you need before gameplay begins.

If it were me, I would first try creating one giant polygon geom, and see if that works.  I would try to have as few verts as possible, but my player object will have many verts.  For example I would subdivide the mountain verts by 20, but the player object but 1.  Experiment. 

If this doesn't work, then I'd break the mountain up, and create reusable "geom tiles" that I would clone on the fly.  I think this is faster than creating geoms on the fly because it doesn't have to recompute the grid which is what I think makes creating geoms on the fly so slow.

If you really want the mountain to be dynamic, you could try creating small sections ahead of time.  I've found creating a couple of smaller geoms on the fly usually doesn't effect performance.  Maybe creating screen length geom with the verts spaced apart widely would be okay.

If you break it up in sections once your player object goes by then take it off the simulation.  Also every alternating mountain geom should probably not collide with each other.

Hope this helps.