0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2024-11-27 09:50:52 -05:00
liabru-matter-js/examples/wreckingBall.js

30 lines
804 B
JavaScript
Raw Normal View History

2015-08-25 14:12:52 -04:00
(function() {
2015-08-25 14:31:44 -04:00
var World = Matter.World,
2015-08-25 14:12:52 -04:00
Bodies = Matter.Bodies,
Composites = Matter.Composites,
2015-08-25 14:31:44 -04:00
Constraint = Matter.Constraint;
2015-08-25 14:12:52 -04:00
Example.wreckingBall = function(demo) {
var engine = demo.engine,
2015-08-25 14:31:44 -04:00
world = engine.world;
2015-08-25 14:12:52 -04:00
var rows = 10,
yy = 600 - 21 - 40 * rows;
2015-08-25 14:31:44 -04:00
var stack = Composites.stack(400, yy, 5, rows, 0, 0, function(x, y) {
2015-08-25 14:12:52 -04:00
return Bodies.rectangle(x, y, 40, 40);
});
World.add(world, stack);
var ball = Bodies.circle(100, 400, 50, { density: 0.04, frictionAir: 0.005});
World.add(world, ball);
World.add(world, Constraint.create({
pointA: { x: 300, y: 100 },
bodyB: ball
}));
};
})();