0
0
Fork 0
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:
liabru 2015-08-25 19:31:44 +01:00
parent b7220126ad
commit 0bff037f85
32 changed files with 53 additions and 100 deletions

View file

@ -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'),

View file

@ -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) {

View file

@ -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 });
});

View file

@ -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 });
});

View file

@ -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 });
});

View file

@ -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));
});

View file

@ -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:

View file

@ -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);
});

View file

@ -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 } });
});

View file

@ -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);
});

View file

@ -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);
});

View file

@ -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 });

View file

@ -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: {

View file

@ -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' } });
});

View file

@ -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:

View file

@ -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

View file

@ -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:

View file

@ -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);
});

View file

@ -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:

View file

@ -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,

View file

@ -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:

View file

@ -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 } } });
});

View file

@ -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: {

View file

@ -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);
});

View file

@ -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,

View file

@ -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);
});

View file

@ -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);
});

View file

@ -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);
}

View file

@ -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:

View file

@ -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:

View file

@ -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);
});

View file

@ -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);