Behind Boxboy…

Behind BoxBoy

Boxboy can run, jump, grab hold of things, balace on top of rolling balls and so much more, which is really amazing with him being only a virtual box.

To figure out this madness, I chased him down and delicately split him apart lengthwise, using CTRL-X to cut, and after digging deep into his physical anatomy this is what I found:

First of all, all he really is a box and a ball, which are connected together by a Motor Joint.

The motor in this Joint is switched on whenever he wants to move, and will roll him over the ground at a constant speed. Like a one wheeled car.

To stop Boxboy falling over at every bump is a Fixed Angle Joint, which keeps his body at a specific angle. As he rolls along over the ground, this angle is adjusted to the angle of whatever he is standing on, and so prevents him from standing unrealistically upright on a slope.

To detect the angle of whatever he is standing on, and also to detect whether or not he is actually standing on anything, are 3 short Rays. These begin just under his Rectangle, and return the distance to the ground and the angle of it.

When Boxboy is standing still an Angle Joint clamps down on both his body and his circle, thus preventing him from rolling away out of control down a slope. Like what a handbrake does.

And thats it folks! I hope you learned somoething!

Box Boy

Sadly though, what I learnt was that I couldn’t put him back together again, but I should be able to figure that out with the next one…

About these ads
Explore posts in the same categories: Other

10 Comments on “Behind Boxboy…”

  1. Dusho Says:

    hey Robert
    thnx for the nice description.
    Boxycraft really looks like fun.. and the level editor looks great too.
    Best of luck with future games..

  2. lagattack Says:

    This looks really cool. Are you using XNA to develop it with the Farseer physics engine? I think I’ve seen you in the forums. Are you planning to make money off of this eventually?

    Best of luck.

    • boxycraft Says:

      Im using Physics2D.NET for physics and SlimDX for Graphics. Ive gotten a lot of help from the Farseer forums and the 2 engines are really similar, which is why Im on there too :)

      Anyway, Im just seeing how it goes, but I might eventually. This is my first propper game, so Ive got no experience marketing or anything.

      Thanks for the response!

  3. CoDinDude29 Says:

    Can I haz source code plx?

    • boxycraft Says:

      The source code will be different for whichever physics engine you are using, so I would suggest using the discussions page of your physics engine for more help with the code.

      If you would like more information of how I handled anything particular though, I will gladly help you out, just visit the contact page and send me an email.


  4. [...] And no, this is not the 4×4 all terrain infinite horsepower brutal Segway of doom ©. This is actually our main character walking around. (It doesn’t look so silly if you imagine a texture of a Dutch girl moving around instead of these funny boxes . The idea to do it this way came from this blog article by Bryan Dismas which in turn is based on this blog article by Robert Dodd [...]


  5. [...] stole the real trick here from Robert Dodd. Basically, the user sprite functions like this My sprite is essentially a square, much like it was [...]

  6. geemge Says:

    Hi, first off, great article!!! I’m working on implementing right now. I’m having trouble getting my motor joint (revolute joint) to actually make my circle spin while attached with these joints. Right now I’m hacking on XNA farseer sample code,
    here is what I’ve got but without luck:
    Both bodies are dynamic.

    bodyRect = BodyFactory.CreateRectangle(world, 1.75f, 1.75f, 1.0f, new Vector2(2.0f, 0.0f));

    bodyCircle = BodyFactory.CreateCircle(world, 1.0f, 1.0f, new Vector2(2.0f, 2.0f));

    revJoint = JointFactory.CreateRevoluteJoint(world, bodyCircle, bodyRect, new Vector2(0.0f, 0.0f));
    fixedAngle = JointFactory.CreateFixedAngleJoint(world, bodyRect);

    //dynAngle = JointFactory.CreateAngleJoint(world, bodyCircle, bodyRect);

    revJoint.LimitEnabled = false;
    revJoint.MotorSpeed = 5.0f;
    revJoint.MotorEnabled = true;

    I was playing with the fixedAngle and dynAngle both between the two bodies but decided to first work on getting motor. Any advice would be great! Thanks =)

    Bryan


  7. [...] of the player character we will implement the concept introduced by Robert Doddin Boxycraft (http://boxycraft.wordpress.com/2009/06/30/behind-boxboy). Every pawn will have a character physics object handling the needs of player and enemy movement. [...]


  8. [...] I am creating a simple platformer using Box2d. I’ve implemented a variant of the technique described here. [...]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.

%d bloggers like this: