Platform engine using Box2D

Platform engines always represented a challenge for me, you can see my prototypes with AS2 and AS3, and this time I am going to make one using Box2D.

Box2D is used as physics engine by PlayCrafter guys, and since the results you can see in Rick Triqui game are really interesting, I’ll start coding my little personal engine to make platform games.

The following script is an adaptation of Platform game basics using Box2D but I am going to add it a lot of options in order to let you use it for your projects.

I am also using the input class included in Box2D, why writing my own one if that one works?

At the moment it’s only a bunch of lines starting from the Hello World example, but starting from tomorrow I’ll code the main character shooting as seen in Rick Triqui.

Here it is the result… no need to download, just copy/paste these lines in the Hello World example.

Next time I’ll add graphics and the bazooka, and obviously I’ll explain the script, meanwhile… left/right arrows to move the player.

  • HiddenSpartan

    Perhaps you could use multiple classes and return types?

  • vogelscheuche

    I like the way you circumvented the body definition’s fixedRotation and let the player tilt a little bit.
    Is this a cure against slopes? Can’t think of a benefit for graphical representation though.

  • I have found Push Button Engine which combines Box2D with other components to make games faster. Maybe you can use it to do something.

  • Pingback: Platform engine using Box2D – Step 2 : Emanuele Feronato()

  • Pingback: Platform engine using Box2D – Step 3 : Emanuele Feronato()

  • Pingback:   Platform engine using Box2D – Step 3 by Blam Yo!()

  • sssig

    i have attached a movieclip to the userdata of my body(b2body)…say myBody.userData = new Xobj(); i have different frame labels inside the movieclip(Xobj) holding different poses.if i place gotoAndStop(“xLabel”); my character is not jumping properly, if i comment the gotoAndStop line, my character is jumping and moving well. So how move between different labels? and what might be the cause for this weird behaviour?

  • Pingback: [box2d][as3] ?? tutorial | CODE@????()