Farseer + Silverlight = Fragile - game freezes with too many geom/body objects

Topics: Developer Forum
Jun 9, 2008 at 1:43 PM
First off, I'm rather new to silverlight and game programming in general.  My assumption that Silverlight and Farseer together make a fragile program is likely based on faulty data and my own lack of said-knowledge.

I've taken the demo project that comes with the Farseer download and used that as a base for my game. In that demo project is a "AddRectangle" (which adds a Body/Geom to the play field) method (found in the SimulatorView class). I've simply used that method to add many objects to my game board. It works well for small boards, but once I add a certain amount, the game simply grinds to a halt then freezes up.

Has anyone else experienced this? Is there something I've done wrong or that I should change? (perhaps using the demo as a base is a bad idea?)

I'd love any thoughts or suggestions about solving this... the amount of bodies I've added is not huge by any means (about 60) and if Silverlight can't handle that, I'd be surprised.
Jun 9, 2008 at 3:01 PM
Update: I thought I would add more information to this about what the game board looks like, as it may prove helpful. I've got my blocks that are set to static objects. They are all sitting on top of each other and touching. I've noticed that if I turn off collission detection on the blocks, then the game runs fine. However, I need them to collide with the player's avatar so they work as a stop.

I'm going to guess that the blocks are all colliding with each other constantly even though I've got them set to static... which seems odd. Is there anyway I can make them behave better?
Jun 17, 2008 at 9:14 PM
I'll have to agree with your experiences.  I've noticed that once I get to a certain number of items (in my case circles) on the screen, the application will start slowing down and eventually freeze up.  The point at which is freezes varies, but I've found when I get near the level of 80 or so entities on the screen it gets a little slow.  I've found that I can increase the number of items I show on the screen by decreasing the number of vertexes I specify when creating my geometries.
Jun 17, 2008 at 9:23 PM
I just did a game in Silverlight 2 beta 2 and I can have 100+ geoms, 500+ bodies, and for the most part people report everything going pretty well.  I have had to tweak more than a thing or two to avoid crashing.  For example if I have too high of a RotationalDragCoefficient that will crash my game everytime.
Jul 5, 2008 at 1:57 PM
Late reply i know but... Have you changed the collision group of the tiles to be all the same? That way they wont be colliding with each over but will collide with the Player