This project has moved. For the latest updates, please go here.

Tutorials from scratch

Topics: Developer Forum
Jul 13, 2011 at 5:16 PM
Hey all, This is my first time using farseer physics and coding a game using XNA, but I am a reasonably capable programmer. My usual language is C# so that's a bonus. I've been looking at the samples and trying to work out what's happening, but I'm struggling to find a starting point. There is quite a lot to take in! Are there any decent, and simple tutorials that start from a totally bare template? Even something as simple as adding a wheel or bouncy ball to the screen? Thanks for any help, Gareth
Jul 14, 2011 at 8:28 AM
Edited Jul 14, 2011 at 8:33 AM

here is one (searching more...) (in german but there are some good tutorials)

and this

Jul 14, 2011 at 10:46 AM

Hi HellGate, thanks for the links.

I've had a quick look at the top one and it looks like exactly what I was looking for.

Also, sorry about the lack of carriage returns in my last post, I sent it from my iPhone and it looks as if they were all ignored for some reason.

Thanks again,


Jul 14, 2011 at 1:40 PM

That tutorial gave me a nice grounding, and I'm beginning to see how things work.

Now I want to make something rotate on the spot, such as a wheel or more specifically a motor (with a set torque, speed, etc).

For this I have found a FixedRevoluteJoint.Is this what I should be using?

Here is the code I have so far, which doesn't work as expected:




_world = new World(new Vector2(0, 0.981f));

fixedRec = new Body(_world);
fixedRec.BodyType = BodyType.Static;
fixedRec.Position = new Vector2(200f, 200f);

motor = new Body(_world);
motor.BodyType = BodyType.Dynamic;
motor.Position = new Vector2(200f, 200f);

motorJoint = new FixedRevoluteJoint(motor, Vector2.Zero, fixedRec.Position);
motorJoint.CollideConnected = false;
motorJoint.MotorSpeed = 2f;
motorJoint.MaxMotorTorque = 400f;
motorJoint.MotorEnabled = true;



spriteBatch.Draw(motorBody, motor.Position, null, Color.White, motorJoint.JointAngle, fixedRec.Position, 1f, SpriteEffects.None, 0f);

The motor is drawn, but for some reason does a large circle rather than rotating on the spot.

Any idea's what I'm doing wrong?