diff --git a/index.js b/index.js index 4e4a34f..7ac6bb5 100644 --- a/index.js +++ b/index.js @@ -8,17 +8,21 @@ let engine = Engine.create({ }, }); +const width = window.innerWidth > 0 ? window.innerWidth : screen.width; +const height = window.innerHeight > 0 ? window.innerHeight : screen.height; +console.log('>>> width, height', width, height); + // create runner let runner = Runner.create(); -let ground = Bodies.rectangle(400, 610, 810, 60, { isStatic: true }); +let ground = Bodies.rectangle(width / 2, height - 300, width / 2, 60, { isStatic: true }); // create a renderer let render = Render.create({ element: document.getElementById("canvas"), engine: engine, options: { - width: 1600, - height: 800, + width: width - 18, + height: height - 150, }, }); @@ -52,7 +56,7 @@ function addShape() { // to be continued // let oneShape = Bodies.circle(80, 80, 80); let oneShape = Bodies.polygon( - Math.random() * 450 + 1, + Math.random() * width / 2 + 12, Math.random() * 450 + 1, Math.random() * 12 + 1, Math.random() * 150 + 100