A small module that handles creating a player that can jump with Box2dweb. Handy for prototyping other parts of a physics-based game - if you're developing your own thing, you'll have better results writing something from scratch!
npm install box2d-player box2dweb-commonjs
Box2D object and get back a player class in return.
var b2Player = Box2D
Creates a player instance, with its body attached to the
world. Takes the
data: the user data to attach to the body. Defaults to
position: the position to create the player at. Defaults to
jumpHeight: the impulse to apply upwards when jumping. Defaults to
body: a body you can use for the player - a default body will be created if not supplied.
fixture: a fixture you can use for the player - otherwise, a circle will be created for you.
Triggers a jump provided there's a physical body below the player and it's not
moving upwards. Returns
true if successful.
Right now you'll still need to control horizontal motion manually - you can do
this by changing the value of the