mirror of
https://github.com/liabru/matter-js.git
synced 2024-12-26 13:49:01 -05:00
demos are now jshinted
This commit is contained in:
parent
1a152309a0
commit
471754611a
3 changed files with 70 additions and 53 deletions
|
@ -41,7 +41,7 @@ module.exports = function(grunt) {
|
||||||
options: {
|
options: {
|
||||||
jshintrc: '.jshintrc'
|
jshintrc: '.jshintrc'
|
||||||
},
|
},
|
||||||
all: ['src/**/*.js', '!src/module/*']
|
all: ['src/**/*.js', 'demo/js/*.js', '!src/module/*']
|
||||||
},
|
},
|
||||||
connect: {
|
connect: {
|
||||||
watch: {
|
watch: {
|
||||||
|
|
102
demo/js/Demo.js
102
demo/js/Demo.js
|
@ -174,20 +174,22 @@
|
||||||
|
|
||||||
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, column, row) {
|
||||||
switch (Math.round(Common.random(0, 1))) {
|
switch (Math.round(Common.random(0, 1))) {
|
||||||
case 0:
|
|
||||||
if (Math.random() < 0.8) {
|
|
||||||
return Bodies.rectangle(x, y, Common.random(20, 50), Common.random(20, 50));
|
|
||||||
} else {
|
|
||||||
return Bodies.rectangle(x, y, Common.random(80, 120), Common.random(20, 30));
|
|
||||||
}
|
|
||||||
case 1:
|
|
||||||
var sides = Math.round(Common.random(1, 8));
|
|
||||||
|
|
||||||
// triangles can be a little unstable, so avoid until fixed
|
case 0:
|
||||||
// TODO: make triangles more stable
|
if (Math.random() < 0.8) {
|
||||||
sides = (sides === 3) ? 4 : sides;
|
return Bodies.rectangle(x, y, Common.random(20, 50), Common.random(20, 50));
|
||||||
|
} else {
|
||||||
|
return Bodies.rectangle(x, y, Common.random(80, 120), Common.random(20, 30));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
var sides = Math.round(Common.random(1, 8));
|
||||||
|
|
||||||
return Bodies.polygon(x, y, sides, Common.random(20, 50));
|
// triangles can be a little unstable, so avoid until fixed
|
||||||
|
// TODO: make triangles more stable
|
||||||
|
sides = (sides === 3) ? 4 : sides;
|
||||||
|
|
||||||
|
return Bodies.polygon(x, y, sides, Common.random(20, 50));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -203,14 +205,17 @@
|
||||||
|
|
||||||
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, column, row) {
|
||||||
switch (Math.round(Common.random(0, 1))) {
|
switch (Math.round(Common.random(0, 1))) {
|
||||||
case 0:
|
|
||||||
if (Math.random() < 0.8) {
|
case 0:
|
||||||
return Bodies.rectangle(x, y, Common.random(20, 50), Common.random(20, 50));
|
if (Math.random() < 0.8) {
|
||||||
} else {
|
return Bodies.rectangle(x, y, Common.random(20, 50), Common.random(20, 50));
|
||||||
return Bodies.rectangle(x, y, Common.random(80, 120), Common.random(20, 30));
|
} else {
|
||||||
}
|
return Bodies.rectangle(x, y, Common.random(80, 120), Common.random(20, 30));
|
||||||
case 1:
|
}
|
||||||
return Bodies.polygon(x, y, Math.round(Common.random(1, 8)), Common.random(20, 50));
|
break;
|
||||||
|
case 1:
|
||||||
|
return Bodies.polygon(x, y, Math.round(Common.random(1, 8)), Common.random(20, 50));
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -326,14 +331,17 @@
|
||||||
|
|
||||||
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, column, row) {
|
||||||
switch (Math.round(Common.random(0, 1))) {
|
switch (Math.round(Common.random(0, 1))) {
|
||||||
case 0:
|
|
||||||
if (Math.random() < 0.8) {
|
case 0:
|
||||||
return Bodies.rectangle(x, y, Common.random(20, 50), Common.random(20, 50));
|
if (Math.random() < 0.8) {
|
||||||
} else {
|
return Bodies.rectangle(x, y, Common.random(20, 50), Common.random(20, 50));
|
||||||
return Bodies.rectangle(x, y, Common.random(80, 120), Common.random(20, 30));
|
} else {
|
||||||
}
|
return Bodies.rectangle(x, y, Common.random(80, 120), Common.random(20, 30));
|
||||||
case 1:
|
}
|
||||||
return Bodies.polygon(x, y, Math.round(Common.random(1, 8)), Common.random(20, 50));
|
break;
|
||||||
|
case 1:
|
||||||
|
return Bodies.polygon(x, y, Math.round(Common.random(1, 8)), Common.random(20, 50));
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -351,14 +359,17 @@
|
||||||
|
|
||||||
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, column, row) {
|
||||||
switch (Math.round(Common.random(0, 1))) {
|
switch (Math.round(Common.random(0, 1))) {
|
||||||
case 0:
|
|
||||||
if (Math.random() < 0.8) {
|
case 0:
|
||||||
return Bodies.rectangle(x, y, Common.random(20, 50), Common.random(20, 50));
|
if (Math.random() < 0.8) {
|
||||||
} else {
|
return Bodies.rectangle(x, y, Common.random(20, 50), Common.random(20, 50));
|
||||||
return Bodies.rectangle(x, y, Common.random(80, 120), Common.random(20, 30));
|
} else {
|
||||||
}
|
return Bodies.rectangle(x, y, Common.random(80, 120), Common.random(20, 30));
|
||||||
case 1:
|
}
|
||||||
return Bodies.polygon(x, y, Math.round(Common.random(1, 8)), Common.random(20, 50));
|
break;
|
||||||
|
case 1:
|
||||||
|
return Bodies.polygon(x, y, Math.round(Common.random(1, 8)), Common.random(20, 50));
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -377,14 +388,17 @@
|
||||||
|
|
||||||
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, column, row) {
|
||||||
switch (Math.round(Common.random(0, 1))) {
|
switch (Math.round(Common.random(0, 1))) {
|
||||||
case 0:
|
|
||||||
if (Math.random() < 0.8) {
|
case 0:
|
||||||
return Bodies.rectangle(x, y, Common.random(20, 50), Common.random(20, 50));
|
if (Math.random() < 0.8) {
|
||||||
} else {
|
return Bodies.rectangle(x, y, Common.random(20, 50), Common.random(20, 50));
|
||||||
return Bodies.rectangle(x, y, Common.random(80, 120), Common.random(20, 30));
|
} else {
|
||||||
}
|
return Bodies.rectangle(x, y, Common.random(80, 120), Common.random(20, 30));
|
||||||
case 1:
|
}
|
||||||
return Bodies.polygon(x, y, Math.round(Common.random(1, 8)), Common.random(20, 50));
|
break;
|
||||||
|
case 1:
|
||||||
|
return Bodies.polygon(x, y, Math.round(Common.random(1, 8)), Common.random(20, 50));
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -136,14 +136,17 @@
|
||||||
|
|
||||||
var stack = Composites.stack(20, 20, 10, 5, 0, 0, function(x, y, column, row) {
|
var stack = Composites.stack(20, 20, 10, 5, 0, 0, function(x, y, column, row) {
|
||||||
switch (Math.round(Common.random(0, 1))) {
|
switch (Math.round(Common.random(0, 1))) {
|
||||||
case 0:
|
|
||||||
if (Math.random() < 0.8) {
|
case 0:
|
||||||
return Bodies.rectangle(x, y, Common.random(20, 40), Common.random(20, 40), { friction: 0.01, restitution: 0.4 });
|
if (Math.random() < 0.8) {
|
||||||
} else {
|
return Bodies.rectangle(x, y, Common.random(20, 40), Common.random(20, 40), { friction: 0.01, restitution: 0.4 });
|
||||||
return Bodies.rectangle(x, y, Common.random(80, 120), Common.random(20, 30), { friction: 0.01, restitution: 0.4 });
|
} else {
|
||||||
}
|
return Bodies.rectangle(x, y, Common.random(80, 120), Common.random(20, 30), { friction: 0.01, restitution: 0.4 });
|
||||||
case 1:
|
}
|
||||||
return Bodies.polygon(x, y, Math.round(Common.random(4, 6)), Common.random(20, 40), { friction: 0.01, restitution: 0.4 });
|
break;
|
||||||
|
case 1:
|
||||||
|
return Bodies.polygon(x, y, Math.round(Common.random(4, 6)), Common.random(20, 40), { friction: 0.01, restitution: 0.4 });
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue