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

Another DBP entry using Farseer: Square Off

Aug 11, 2009 at 4:11 PM

Big thanks to the Farseer team. Even though it doesn't really use any of Farseer's more advanced features (just collision and basic dynamics), I still owe you guys a lot of cred.

Here's the video link


Aug 11, 2009 at 5:09 PM

Great game roonda. I like just about everything about it - good luck with DBP.

Can I ask what kind of libs you used besides Farseer Physics (if any)?

Aug 11, 2009 at 10:18 PM

Looks a lot of fun! Is already available on Xbox's Indie Games?

Aug 12, 2009 at 8:36 AM

Thanks guys :)

@genbox No other libs, I used some of the gpu particle and post process distortion code from the creators website. Other than those (and Farseer of course), it's all my own tech. Oh - it used ContentTracker (which is my own lib on CodePlex) during development for loading X files. One big success was the 2D character editor. That allowed me to edit the relationships between different quads and do spritesheet animations in one tool. But the main reason(s) it looks so cool are my two artist buddies :)

@pnikosis Not yet, actually it's in Playtest already so you can try it if you want. Playtest ends in two days but I'll submit it again right after I think (nobody has commented on it yet!). We'll probably try to add a few more levels, some essential features and bit more polish and release it on XBLIG in a few months.

Aug 12, 2009 at 10:40 AM

It looks terribly cool indeed! The characters are pretty adorable in a destructive way :P The 2D character editor you used is a custom one? I mean, you didn't download an existing tool and made your own?

Right now, what I'm fighting against is with the animations, my artist is an awesome illustrator, but not a very good animator, so I'm looking for a tool for simplifying the animation process (make the character run, jump, crouch), anyway... Just wanted to know which specific tool you used :P


Aug 12, 2009 at 3:39 PM

I wrote about your game on my blog: What ever crossed my mind

Can I include your game on our engine usage list?

Aug 12, 2009 at 4:54 PM
Edited Aug 12, 2009 at 4:55 PM

@pnikosis - You inspired me to post about the tool on our blog. It is in-house, and as I say in the blog I'm not yet comfortable foisting on my own team, but eventually I'd like to release it publicly, possibly with source.

@genbox - Absolutely! Honoured, and thanks for the props! :D


Aug 12, 2009 at 9:56 PM

Roonda, after reading your blog post I must say that this was exactly (as I understood :S) the idea I had in mind for a character editor. Some kind of editor where you enter limbs and other parts and place and move them for constructing the animation sprite sheet. Brilliant!

I'll look for your game as soon as it is public :)

Aug 14, 2009 at 2:21 AM

Looks smooth.  Looking at your blog I see you define a platform using XML. Do you use XML to define your entire levels?

Aug 15, 2009 at 6:37 PM

Thanks guys.

@Fixitchris, yeah, level settings and almost all game objects are deserialized from XML. XNA's IntermediateSerializer is gold for doing this.

If you're interested in the details, read on. It may be rather a crazy way of doing things, but it feels easier than XmlSerializer (which works but is painful) and the more standard ContentPipeline approach (which works really well but is quite complex. In the end mine was probably less powerful and almost as complex, but I'm stuck with it now :)).

Like the standard ContentPipeline, most of my Component sub-classes have their own specific class that gets serialized. My approach is different by making them all ComponentSettings sub-classes. These settings classes are pretty simple and serialize without special code (they avoid shared references etc). ComponentSettings has a field called ClassName and so knows how to construct it's associated Component (via Activator). Levels have a LevelSettings object (or xml file), which consists of level properties plus a list of all the ComponentSettings providing data for the level's components.

One downside is that as you build an inheritance hierarchy, you find yourself with an almost identical hierarchy of settings classes - it's like you're writing two classes for every one!. One upside is that your game logic classes don't have to have any unsightly XML attributes.

Aug 16, 2009 at 3:18 AM

@roonda: your description makes some sense.  the ClassName field basically defines the type of level object (platform, enemy, character, etc).  Then it looks like you derive from some base class to create concreate types of each ClassName.

How about interaction between objects?  eg. the 'x4 devastator' move at the end of the video... how do you determine the blast radius and do you find yourself using the broad phase collision event much?

Aug 16, 2009 at 6:18 AM
Edited Aug 16, 2009 at 6:36 PM

That's exactly right fixitchris.

The LevelScreen class maintains lists of all alive enemies and players. The explosions are handled by the missiles/bombs themselves. I iterate the screen's enemies list and apply some damage based on distance to the blast. The "bool DoDamage(float amount)" method returns whether the entity was killed. I keep a count for that blast and then basically call "RegisterMultiKill(int playerId, int numKills)" on the LevelScreen class.

I looked into using the broad phase collision, but I already had those lists set up and I didn't end up going down that path. Even for render culling and physics enable/disable, I just keep a 2D box (a bit bigger than what the camera can see) and test the object centres against that.

Most other object interactions use the standard OnCollision events and the Geom.Tag holds a reference to the actual objects. I also used the Geom.CollisionCategories and Geom.CollidesWith to help determine the type of objects colliding and which should not collide.

Aug 16, 2009 at 6:12 PM

I'm glad I'm not the only one using the Tag property of Body and Geom. 

I am using FlatRedBall with Farseer for 2D development.  I have a PhysicalObject class which derives from FRB.PositionedObject and has a FRB.Sprite, Farseer.Body and Farseer.Geom.  So since the Geom is used to handle collisions, I have to have a reference in the Geom.Tag to my PhysicalObject.

The culling/physics solution is a pretty good idea.  I am planning on using an Active PhysicalObject List and Inactive PhysicalObject List , moving from one to another based on the camera position and fulcrum size.

Do you use a State Design Pattern for object interaction/state transitions?

Aug 17, 2009 at 11:45 AM
Edited Aug 17, 2009 at 11:48 AM

By the way, probably you already know roonda, but you have a nice short article in Xbox Indies dot com:

Edit: As I see in the comments, you already saw the article :P

Aug 18, 2009 at 7:42 AM
fixitchris wrote:

Do you use a State Design Pattern for object interaction/state transitions?

Not really. My menu system does, and I started out with the intention of doing it for every entity (players, enemies etc), but in the end most of the entities were so simple they didn't warrant it. Back when it was a platformer, I found it really helpful for the jump/walk transitions, but I scrapped it for the Square Off players. I may live to regret it though :)

@pnikosis: Thanks anyway for the heads up. What an awesome review :D