A small module that handles creating a player that can jump with Box2dweb
Want to see pretty graphs? Log in now!
npm install box2d-player
|2||downloads in the last week|
|8||downloads in the last month|
|Last Published By|
|Version||0.1.0 last updated 8 months ago|
|Keywords||platformer, physics, box2d, game|
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
b2Player = require('box2d-player)(Box2D)
Box2D object and get back a player class in return.
var b2Player = require('box2d-player')(require('box2dweb-commonjs').Box2D)
player = b2Player(world[, options])
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