UNPKG

newton

Version:

A playful, particle-based physics engine designed from the ground up for JavaScript.

16 lines (10 loc) 394 B
p. In most cases, you'll extend Newton's base Body to create reusable custom Body types. For example, let's create a Rope Body: pre.CodeBlock. function Rope(x, y, length) { Newton.Body.call(this); // call Body's constructor // implementation here } Rope.prototype = Object.create(Newton.Body.prototype); // extend Body's prototype var rope = new Rope(225, 10, 300);