initial addShape
This commit is contained in:
parent
79db880eb4
commit
94ce67d1b4
1 changed files with 7 additions and 11 deletions
18
index.js
18
index.js
|
@ -14,16 +14,10 @@ let render = Render.create({
|
|||
engine: engine,
|
||||
});
|
||||
|
||||
// create two boxes and a ground
|
||||
let boxA = Bodies.rectangle(400, 200, 80, 200);
|
||||
let boxB = Bodies.rectangle(450, 50, 80, 80);
|
||||
let triangle = Bodies.polygon(350, 200, 5, 80);
|
||||
let ground = Bodies.rectangle(400, 610, 810, 60, { isStatic: true });
|
||||
|
||||
function kaboom() {
|
||||
let manyShapes = new Array(300)
|
||||
.fill({})
|
||||
.map((item) =>
|
||||
.fill()
|
||||
.map(() =>
|
||||
Bodies.polygon(
|
||||
Math.random() * 450 + 1,
|
||||
Math.random() * 450 + 1,
|
||||
|
@ -32,14 +26,16 @@ function kaboom() {
|
|||
)
|
||||
);
|
||||
|
||||
console.log(manyShapes);
|
||||
|
||||
generateWorld(manyShapes);
|
||||
}
|
||||
|
||||
function addShape() {
|
||||
// to be continued
|
||||
}
|
||||
|
||||
function generateWorld(shapes) {
|
||||
// add all of the bodies to the world
|
||||
// Composite.add(engine.world, [boxA, boxB, triangle, ground]);
|
||||
let ground = Bodies.rectangle(400, 610, 810, 60, { isStatic: true });
|
||||
Composite.add(engine.world, [...shapes, ground]);
|
||||
|
||||
// run the renderer
|
||||
|
|
Loading…
Reference in a new issue