jPhysics
November 1, 2008 - 10:18pm — rcparts
This plugin gives physics properties to selected DOM elements. You set position, velocity, acceleration, apply forces and update the elements states. You also get a n-dimensional Vector class with basic vectorial operations. Specially useful for JS games.
Example:
//Applies physics properties to element with 'box' id
$('#box').physics({
position:new $.Vector(0,400),
velocity:new $.Vector(5,-10)),
maxVelocity:new $.Vector(10,10),
minVelocity:new $.Vector(-10,-10),
minPosition:new $.Vector(0,0),
maxPosition:new $.Vector(800,400)
});
//Defines 2 forces
var gravity = new $.Vector(0,0.2);
var wind = new $.Vector(-0.05,0);
//Sets a timer with 30ms interval to apply the 2 forces and update element state
//Applies 3 time steps per update
setInterval('$("#box").applyForces(gravity,wind).updatePhysics(3)',30);Releases
| Official releases | Date | Size | Links | Status | |
|---|---|---|---|---|---|
| 0.3 | 2008-Nov-02 | 7.5 KB | Recommended for 1.2.x | ||
