mirror of
https://github.com/liabru/matter-js.git
synced 2025-01-10 15:50:44 -05:00
removed unused vars from examples
This commit is contained in:
parent
b7220126ad
commit
0bff037f85
32 changed files with 53 additions and 100 deletions
|
@ -153,7 +153,7 @@ module.exports = function(grunt) {
|
|||
|
||||
grunt.registerTask('default', ['concat:examples', 'test', 'build']);
|
||||
grunt.registerTask('test', ['build:dev', 'connect:serve', 'jshint', 'test:demo', 'test:demoNode']);
|
||||
grunt.registerTask('dev', ['build:dev', 'connect:watch', 'watch']);
|
||||
grunt.registerTask('dev', ['concat:examples', 'build:dev', 'connect:watch', 'watch']);
|
||||
|
||||
grunt.registerTask('test:demo', function() {
|
||||
var updateAll = grunt.option('updateAll'),
|
||||
|
|
|
@ -14,10 +14,12 @@
|
|||
// Matter aliases
|
||||
var Example = Matter.Example,
|
||||
Engine = Matter.Engine,
|
||||
World = Matter.World
|
||||
World = Matter.World,
|
||||
Common = Matter.Common,
|
||||
Bodies = Matter.Bodies,
|
||||
Events = Matter.Events;
|
||||
Events = Matter.Events,
|
||||
Mouse = Matter.Mouse,
|
||||
MouseConstraint = Matter.MouseConstraint;
|
||||
|
||||
// MatterTools aliases
|
||||
if (window.MatterTools) {
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
var engine = demo.engine,
|
||||
world = engine.world;
|
||||
|
||||
var stack = Composites.stack(20, 20, 20, 5, 0, 0, function(x, y, column, row) {
|
||||
var stack = Composites.stack(20, 20, 20, 5, 0, 0, function(x, y) {
|
||||
return Bodies.circle(x, y, Common.random(10, 20), { friction: 0.00001, restitution: 0.5, density: 0.001 });
|
||||
});
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
var engine = demo.engine,
|
||||
world = engine.world;
|
||||
|
||||
var stack = Composites.stack(100, 50, 10, 15, 10, 10, function(x, y, column, row) {
|
||||
var stack = Composites.stack(100, 50, 10, 15, 10, 10, function(x, y) {
|
||||
return Bodies.circle(x, y, Common.random(15, 30), { restitution: 0.6, friction: 0.1 });
|
||||
});
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
var engine = demo.engine,
|
||||
world = engine.world;
|
||||
|
||||
var stack = Composites.stack(0, 100, 5, 1, 20, 0, function(x, y, column, row) {
|
||||
var stack = Composites.stack(0, 100, 5, 1, 20, 0, function(x, y) {
|
||||
return Bodies.circle(x, y, 75, { restitution: 0.9 });
|
||||
});
|
||||
|
||||
|
|
|
@ -12,13 +12,13 @@
|
|||
world = engine.world,
|
||||
group = Body.nextGroup(true);
|
||||
|
||||
var bridge = Composites.stack(150, 300, 9, 1, 10, 10, function(x, y, column, row) {
|
||||
var bridge = Composites.stack(150, 300, 9, 1, 10, 10, function(x, y) {
|
||||
return Bodies.rectangle(x, y, 50, 20, { collisionFilter: { group: group } });
|
||||
});
|
||||
|
||||
Composites.chain(bridge, 0.5, 0, -0.5, 0, { stiffness: 0.9 });
|
||||
|
||||
var stack = Composites.stack(200, 40, 6, 3, 0, 0, function(x, y, column, row) {
|
||||
var stack = Composites.stack(200, 40, 6, 3, 0, 0, function(x, y) {
|
||||
return Bodies.polygon(x, y, Math.round(Common.random(1, 8)), Common.random(20, 40));
|
||||
});
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
var engine = demo.engine,
|
||||
world = engine.world;
|
||||
|
||||
var stack = Composites.stack(20, 20, 20, 5, 0, 0, function(x, y, column, row) {
|
||||
var stack = Composites.stack(20, 20, 20, 5, 0, 0, function(x, y) {
|
||||
switch (Math.round(Common.random(0, 1))) {
|
||||
|
||||
case 0:
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
var engine = demo.engine,
|
||||
world = engine.world;
|
||||
|
||||
var stack = Composites.stack(250, 255, 1, 6, 0, 0, function(x, y, column, row) {
|
||||
var stack = Composites.stack(250, 255, 1, 6, 0, 0, function(x, y) {
|
||||
return Bodies.rectangle(x, y, 30, 30);
|
||||
});
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
world = engine.world,
|
||||
group = Body.nextGroup(true);
|
||||
|
||||
var ropeA = Composites.stack(200, 100, 5, 2, 10, 10, function(x, y, column, row) {
|
||||
var ropeA = Composites.stack(200, 100, 5, 2, 10, 10, function(x, y) {
|
||||
return Bodies.rectangle(x, y, 50, 20, { collisionFilter: { group: group } });
|
||||
});
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
|||
|
||||
group = Body.nextGroup(true);
|
||||
|
||||
var ropeB = Composites.stack(500, 100, 5, 2, 10, 10, function(x, y, column, row) {
|
||||
var ropeB = Composites.stack(500, 100, 5, 2, 10, 10, function(x, y) {
|
||||
return Bodies.circle(x, y, 20, { collisionFilter: { group: group } });
|
||||
});
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
var engine = demo.engine,
|
||||
world = engine.world;
|
||||
|
||||
var stack = Composites.stack(100, 100, 10, 10, 20, 0, function(x, y, column, row) {
|
||||
var stack = Composites.stack(100, 100, 10, 10, 20, 0, function(x, y) {
|
||||
return Bodies.circle(x, y, 20);
|
||||
});
|
||||
|
||||
|
|
|
@ -9,10 +9,9 @@
|
|||
Example.compositeManipulation = function(demo) {
|
||||
var engine = demo.engine,
|
||||
world = engine.world,
|
||||
mouseConstraint = demo.mouseConstraint,
|
||||
sceneEvents = demo.sceneEvents;
|
||||
|
||||
var stack = Composites.stack(200, 200, 4, 4, 0, 0, function(x, y, column, row) {
|
||||
var stack = Composites.stack(200, 200, 4, 4, 0, 0, function(x, y) {
|
||||
return Bodies.rectangle(x, y, 40, 40);
|
||||
});
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
world = engine.world;
|
||||
var size = 50;
|
||||
|
||||
var stack = Composites.stack(100, 220, 12, 6, 0, 0, function(x, y, column, row) {
|
||||
var stack = Composites.stack(100, 220, 12, 6, 0, 0, function(x, y) {
|
||||
var partA = Bodies.rectangle(x, y, size, size / 5),
|
||||
partB = Bodies.rectangle(x, y, size / 5, size, { render: partA.render });
|
||||
|
||||
|
|
|
@ -1,15 +1,9 @@
|
|||
(function() {
|
||||
|
||||
var Engine = Matter.Engine,
|
||||
World = Matter.World,
|
||||
var World = Matter.World,
|
||||
Bodies = Matter.Bodies,
|
||||
Body = Matter.Body,
|
||||
Composite = Matter.Composite,
|
||||
Composites = Matter.Composites,
|
||||
Common = Matter.Common,
|
||||
Constraint = Matter.Constraint,
|
||||
Events = Matter.Events,
|
||||
Bounds = Matter.Bounds,
|
||||
Vertices = Matter.Vertices;
|
||||
|
||||
Example.concave = function(demo) {
|
||||
|
@ -21,7 +15,7 @@
|
|||
star = Vertices.fromPath('50 0 63 38 100 38 69 59 82 100 50 75 18 100 31 59 0 38 37 38'),
|
||||
horseShoe = Vertices.fromPath('35 7 19 17 14 38 14 58 25 79 45 85 65 84 65 66 46 67 34 59 30 44 33 29 45 23 66 23 66 7 53 7');
|
||||
|
||||
var stack = Composites.stack(50, 50, 6, 4, 10, 10, function(x, y, column, row) {
|
||||
var stack = Composites.stack(50, 50, 6, 4, 10, 10, function(x, y) {
|
||||
var color = Common.choose(['#556270', '#4ECDC4', '#C7F464', '#FF6B6B', '#C44D58']);
|
||||
return Bodies.fromVertices(x, y, Common.choose([arrow, chevron, star, horseShoe]), {
|
||||
render: {
|
||||
|
|
|
@ -129,7 +129,7 @@
|
|||
|
||||
// scene code
|
||||
|
||||
var stack = Composites.stack(50, 100, 8, 4, 50, 50, function(x, y, column, row) {
|
||||
var stack = Composites.stack(50, 100, 8, 4, 50, 50, function(x, y) {
|
||||
return Bodies.circle(x, y, 15, { restitution: 1, render: { strokeStyle: '#777' } });
|
||||
});
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
engine.world.gravity.y = -1;
|
||||
|
||||
var stack = Composites.stack(20, 20, 20, 5, 0, 0, function(x, y, column, row) {
|
||||
var stack = Composites.stack(20, 20, 20, 5, 0, 0, function(x, y) {
|
||||
switch (Math.round(Common.random(0, 1))) {
|
||||
|
||||
case 0:
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
var engine = demo.engine,
|
||||
world = engine.world;
|
||||
|
||||
var stack = Composites.stack(20, 20, 15, 4, 0, 0, function(x, y, column, row) {
|
||||
var stack = Composites.stack(20, 20, 15, 4, 0, 0, function(x, y) {
|
||||
var sides = Math.round(Common.random(1, 8));
|
||||
|
||||
// triangles can be a little unstable, so avoid until fixed
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
var engine = demo.engine,
|
||||
world = engine.world;
|
||||
|
||||
var stack = Composites.stack(50, 50, 12, 3, 0, 0, function(x, y, column, row) {
|
||||
var stack = Composites.stack(50, 50, 12, 3, 0, 0, function(x, y) {
|
||||
switch (Math.round(Common.random(0, 1))) {
|
||||
|
||||
case 0:
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
var engine = demo.engine,
|
||||
world = engine.world;
|
||||
|
||||
var stack = Composites.pyramid(100, 258, 15, 10, 0, 0, function(x, y, column, row) {
|
||||
var stack = Composites.pyramid(100, 258, 15, 10, 0, 0, function(x, y) {
|
||||
return Bodies.rectangle(x, y, 40, 40);
|
||||
});
|
||||
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
(function() {
|
||||
|
||||
var Engine = Matter.Engine,
|
||||
World = Matter.World,
|
||||
var World = Matter.World,
|
||||
Bodies = Matter.Bodies,
|
||||
Composite = Matter.Composite,
|
||||
Composites = Matter.Composites,
|
||||
Common = Matter.Common,
|
||||
Events = Matter.Events,
|
||||
Vertices = Matter.Vertices,
|
||||
Mouse = Matter.Mouse,
|
||||
Query = Matter.Query;
|
||||
|
||||
Example.raycasting = function(demo) {
|
||||
|
@ -17,7 +15,7 @@
|
|||
sceneEvents = demo.sceneEvents,
|
||||
mouseConstraint = demo.mouseConstraint;
|
||||
|
||||
var stack = Composites.stack(20, 20, 15, 4, 0, 0, function(x, y, column, row) {
|
||||
var stack = Composites.stack(20, 20, 15, 4, 0, 0, function(x, y) {
|
||||
switch (Math.round(Common.random(0, 1))) {
|
||||
|
||||
case 0:
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
(function() {
|
||||
|
||||
var World = Matter.World,
|
||||
Bodies = Matter.Bodies,
|
||||
Common = Matter.Common;
|
||||
Bodies = Matter.Bodies;
|
||||
|
||||
Example.restitution = function(demo) {
|
||||
var engine = demo.engine,
|
||||
|
|
|
@ -3,13 +3,14 @@
|
|||
var World = Matter.World,
|
||||
Bodies = Matter.Bodies,
|
||||
Composites = Matter.Composites,
|
||||
Common = Matter.Common;
|
||||
Common = Matter.Common,
|
||||
Events = Matter.Events;
|
||||
|
||||
Example.sleeping = function(demo) {
|
||||
var engine = demo.engine,
|
||||
world = engine.world;
|
||||
|
||||
var stack = Composites.stack(50, 50, 12, 3, 0, 0, function(x, y, column, row) {
|
||||
var stack = Composites.stack(50, 50, 12, 3, 0, 0, function(x, y) {
|
||||
switch (Math.round(Common.random(0, 1))) {
|
||||
|
||||
case 0:
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
}
|
||||
});
|
||||
|
||||
var pyramid = Composites.pyramid(500, 300, 9, 10, 0, 0, function(x, y, column, row) {
|
||||
var pyramid = Composites.pyramid(500, 300, 9, 10, 0, 0, function(x, y, column) {
|
||||
var texture = column % 2 === 0 ? './img/block.png' : './img/block-2.png';
|
||||
return Bodies.rectangle(x, y, 25, 40, { render: { sprite: { texture: texture } } });
|
||||
});
|
||||
|
@ -40,7 +40,7 @@
|
|||
}
|
||||
});
|
||||
|
||||
var pyramid2 = Composites.pyramid(550, 0, 5, 10, 0, 0, function(x, y, column, row) {
|
||||
var pyramid2 = Composites.pyramid(550, 0, 5, 10, 0, 0, function(x, y, column) {
|
||||
var texture = column % 2 === 0 ? './img/block.png' : './img/block-2.png';
|
||||
return Bodies.rectangle(x, y, 25, 40, { render: { sprite: { texture: texture } } });
|
||||
});
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
var World = Matter.World,
|
||||
Bodies = Matter.Bodies,
|
||||
Composites = Matter.Composites;
|
||||
Composites = Matter.Composites,
|
||||
Common = Matter.Common;
|
||||
|
||||
Example.sprites = function(demo) {
|
||||
var engine = demo.engine,
|
||||
world = engine.world,
|
||||
mouseConstraint = demo.mouseConstraint,
|
||||
offset = 10,
|
||||
options = {
|
||||
isStatic: true,
|
||||
|
@ -26,7 +26,7 @@
|
|||
Bodies.rectangle(-offset, 300, 50.5, 600.5 + 2 * offset, options)
|
||||
]);
|
||||
|
||||
var stack = Composites.stack(20, 20, 10, 4, 0, 0, function(x, y, column, row) {
|
||||
var stack = Composites.stack(20, 20, 10, 4, 0, 0, function(x, y) {
|
||||
if (Common.random() > 0.35) {
|
||||
return Bodies.rectangle(x, y, 64, 64, {
|
||||
render: {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
var engine = demo.engine,
|
||||
world = engine.world;
|
||||
|
||||
var stack = Composites.stack(100, 300, 10, 5, 0, 0, function(x, y, column, row) {
|
||||
var stack = Composites.stack(100, 300, 10, 5, 0, 0, function(x, y) {
|
||||
return Bodies.rectangle(x, y, 40, 40);
|
||||
});
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
size = 50,
|
||||
counter = -1;
|
||||
|
||||
var stack = Composites.stack(350, 470 - 6 * size, 1, 6, 0, 0, function(x, y, column, row) {
|
||||
var stack = Composites.stack(350, 470 - 6 * size, 1, 6, 0, 0, function(x, y) {
|
||||
return Bodies.rectangle(x, y, size * 2, size, {
|
||||
slop: 0.5,
|
||||
friction: 1,
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
var engine = demo.engine,
|
||||
world = engine.world;
|
||||
|
||||
var stack = Composites.stack(90, 50, 18, 15, 0, 0, function(x, y, column, row) {
|
||||
var stack = Composites.stack(90, 50, 18, 15, 0, 0, function(x, y) {
|
||||
return Bodies.rectangle(x, y, 35, 35);
|
||||
});
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
var engine = demo.engine,
|
||||
world = engine.world;
|
||||
|
||||
var stack = Composites.stack(100, 120, 25, 18, 0, 0, function(x, y, column, row) {
|
||||
var stack = Composites.stack(100, 120, 25, 18, 0, 0, function(x, y) {
|
||||
return Bodies.rectangle(x, y, 25, 25);
|
||||
});
|
||||
|
||||
|
|
|
@ -1,19 +1,9 @@
|
|||
(function() {
|
||||
|
||||
var Engine = Matter.Engine,
|
||||
World = Matter.World,
|
||||
var World = Matter.World,
|
||||
Bodies = Matter.Bodies,
|
||||
Body = Matter.Body,
|
||||
Composite = Matter.Composite,
|
||||
Composites = Matter.Composites,
|
||||
Common = Matter.Common,
|
||||
Constraint = Matter.Constraint,
|
||||
Events = Matter.Events,
|
||||
Bounds = Matter.Bounds,
|
||||
Vector = Matter.Vector,
|
||||
Vertices = Matter.Vertices,
|
||||
MouseConstraint = Matter.MouseConstraint,
|
||||
Mouse = Matter.Mouse,
|
||||
Query = Matter.Query,
|
||||
Svg = Matter.Svg;
|
||||
|
||||
|
@ -49,7 +39,7 @@
|
|||
restitution: 0.6
|
||||
};
|
||||
|
||||
World.add(world, Composites.stack(80, 100, 20, 20, 10, 10, function(x, y, column, row) {
|
||||
World.add(world, Composites.stack(80, 100, 20, 20, 10, 10, function(x, y) {
|
||||
if (Query.point([terrain], { x: x, y: y }).length === 0) {
|
||||
return Bodies.polygon(x, y, 5, 12, bodyOptions);
|
||||
}
|
||||
|
|
|
@ -1,21 +1,12 @@
|
|||
(function() {
|
||||
|
||||
var Engine = Matter.Engine,
|
||||
World = Matter.World,
|
||||
var World = Matter.World,
|
||||
Bodies = Matter.Bodies,
|
||||
Body = Matter.Body,
|
||||
Composite = Matter.Composite,
|
||||
Composites = Matter.Composites,
|
||||
Common = Matter.Common,
|
||||
Constraint = Matter.Constraint,
|
||||
Events = Matter.Events,
|
||||
Bounds = Matter.Bounds,
|
||||
Vector = Matter.Vector,
|
||||
Vertices = Matter.Vertices,
|
||||
MouseConstraint = Matter.MouseConstraint,
|
||||
Mouse = Matter.Mouse,
|
||||
Query = Matter.Query,
|
||||
Svg = Matter.Svg;
|
||||
Events = Matter.Events;
|
||||
|
||||
Example.timescale = function(demo) {
|
||||
var engine = demo.engine,
|
||||
|
@ -75,12 +66,12 @@
|
|||
};
|
||||
|
||||
// add some small bouncy circles... remember Swordfish?
|
||||
World.add(world, Composites.stack(20, 100, 15, 3, 20, 40, function(x, y, column, row) {
|
||||
World.add(world, Composites.stack(20, 100, 15, 3, 20, 40, function(x, y) {
|
||||
return Bodies.circle(x, y, Common.random(10, 20), bodyOptions);
|
||||
}));
|
||||
|
||||
// add some larger random bouncy objects
|
||||
World.add(world, Composites.stack(50, 50, 8, 3, 0, 0, function(x, y, column, row) {
|
||||
World.add(world, Composites.stack(50, 50, 8, 3, 0, 0, function(x, y) {
|
||||
switch (Math.round(Common.random(0, 1))) {
|
||||
|
||||
case 0:
|
||||
|
|
|
@ -1,21 +1,13 @@
|
|||
(function() {
|
||||
|
||||
var Engine = Matter.Engine,
|
||||
World = Matter.World,
|
||||
var World = Matter.World,
|
||||
Bodies = Matter.Bodies,
|
||||
Body = Matter.Body,
|
||||
Composite = Matter.Composite,
|
||||
Composites = Matter.Composites,
|
||||
Common = Matter.Common,
|
||||
Constraint = Matter.Constraint,
|
||||
Events = Matter.Events,
|
||||
Bounds = Matter.Bounds,
|
||||
Vector = Matter.Vector,
|
||||
Vertices = Matter.Vertices,
|
||||
MouseConstraint = Matter.MouseConstraint,
|
||||
Mouse = Matter.Mouse,
|
||||
Query = Matter.Query,
|
||||
Svg = Matter.Svg;
|
||||
Mouse = Matter.Mouse;
|
||||
|
||||
Example.views = function(demo) {
|
||||
var engine = demo.engine,
|
||||
|
@ -23,7 +15,7 @@
|
|||
sceneEvents = demo.sceneEvents,
|
||||
mouseConstraint = demo.mouseConstraint;
|
||||
|
||||
var stack = Composites.stack(20, 20, 15, 4, 0, 0, function(x, y, column, row) {
|
||||
var stack = Composites.stack(20, 20, 15, 4, 0, 0, function(x, y) {
|
||||
switch (Math.round(Common.random(0, 1))) {
|
||||
|
||||
case 0:
|
||||
|
|
|
@ -1,31 +1,18 @@
|
|||
(function() {
|
||||
|
||||
var Engine = Matter.Engine,
|
||||
World = Matter.World,
|
||||
var World = Matter.World,
|
||||
Bodies = Matter.Bodies,
|
||||
Body = Matter.Body,
|
||||
Composite = Matter.Composite,
|
||||
Composites = Matter.Composites,
|
||||
Common = Matter.Common,
|
||||
Constraint = Matter.Constraint,
|
||||
Events = Matter.Events,
|
||||
Bounds = Matter.Bounds,
|
||||
Vector = Matter.Vector,
|
||||
Vertices = Matter.Vertices,
|
||||
MouseConstraint = Matter.MouseConstraint,
|
||||
Mouse = Matter.Mouse,
|
||||
Query = Matter.Query,
|
||||
Svg = Matter.Svg;
|
||||
Constraint = Matter.Constraint;
|
||||
|
||||
Example.wreckingBall = function(demo) {
|
||||
var engine = demo.engine,
|
||||
world = engine.world,
|
||||
mouseConstraint = demo.mouseConstraint;
|
||||
world = engine.world;
|
||||
|
||||
var rows = 10,
|
||||
yy = 600 - 21 - 40 * rows;
|
||||
|
||||
var stack = Composites.stack(400, yy, 5, rows, 0, 0, function(x, y, column, row) {
|
||||
var stack = Composites.stack(400, yy, 5, rows, 0, 0, function(x, y) {
|
||||
return Bodies.rectangle(x, y, 40, 40);
|
||||
});
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ var resurrect = new Resurrect({ cleanup: true, revive: false }),
|
|||
created = [],
|
||||
changed = [];
|
||||
|
||||
var test = function(status) {
|
||||
var test = function() {
|
||||
var demos = getDemoNames();
|
||||
|
||||
removeDir(diffsPath);
|
||||
|
|
Loading…
Reference in a new issue