Skip to content

Commit

Permalink
added Demo.concave, added Bodies.fromVertices, added Vertices.isConve…
Browse files Browse the repository at this point in the history
…x, fixed compound properties
  • Loading branch information
liabru committed Feb 1, 2015
1 parent d2f79b4 commit 0b8efa5
Show file tree
Hide file tree
Showing 6 changed files with 842 additions and 8 deletions.
4 changes: 4 additions & 0 deletions demo/dev.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
<meta name="viewport" content="width=device-width,minimal-ui">
<meta name="robots" content="noindex">

<!-- only required if using Bodies.fromVertices with concave vertices -->
<script type="text/javascript" src="./js/lib/decomp.js"></script>

<!-- only required if using Matter.RenderPixi -->
<script type="text/javascript" src="./js/lib/pixi.dev.js"></script>

Expand All @@ -32,6 +35,7 @@ <h1>Matter.js Demo (Dev. Build)</h1>
<option value="mixed">Mixed Shapes</option>
<option value="mixedSolid">Solid Rendering</option>
<option value="compound">Compound Bodies</option>
<option value="concave">Concave Bodies</option>
<option value="newtonsCradle">Newton's Cradle</option>
<option value="wreckingBall">Wrecking Ball</option>
<option value="slingshot">Slingshot Game</option>
Expand Down
22 changes: 20 additions & 2 deletions demo/js/Demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,6 @@
});

World.add(_world, compound);

_world.gravity.y = 1;

var renderOptions = _engine.render.options;
renderOptions.showCollisions = true;
Expand All @@ -141,6 +139,26 @@
renderOptions.showConvexHulls = true;
};

Demo.concave = function() {
var _world = _engine.world;

Demo.reset();

var vertices = Matter.Vertices.fromPath('354 89,336 118,310 145,302 227,322 271,375 292,490 289,539 271,540 233,549 133,526 100,552 36,601 63,633 122,628 227,594 304,505 340,426 340,327 330,265 294,246 242,246 181,256 133,283 81,346 44');
//var vertices = Matter.Vertices.fromPath('164 171,232 233,213 302,273 241,342 305,316 231,364 170,309 188,281 117,240 182');

var concave = Bodies.fromVertices(200, 200, vertices);
World.add(_world, concave);

var renderOptions = _engine.render.options;
renderOptions.showCollisions = true;
renderOptions.showBounds = true;
renderOptions.showAxes = true;
renderOptions.showPositions = true;
renderOptions.showConvexHulls = true;
//renderOptions.showVertexNumbers = true;
};

Demo.slingshot = function() {
var _world = _engine.world;

Expand Down
Loading

0 comments on commit 0b8efa5

Please sign in to comment.