diff --git a/public/static/js/wingbase/render/body.js b/public/static/js/wingbase/render/body.js index c6d1d4c..b1042a5 100644 --- a/public/static/js/wingbase/render/body.js +++ b/public/static/js/wingbase/render/body.js @@ -13,6 +13,18 @@ class BodyRenderer { let pallet = this.pallet; let context = pallet.context; + let limits = { + left: game.world.center.x - pallet.canvas.width / 2 - 100, + right: game.world.center.x + pallet.canvas.width / 2 + 100, + top: game.world.center.y - pallet.canvas.height / 2 - 100, + bottom: game.world.center.y + pallet.canvas.height / 2 + 100 + }; + + if (x > limits.right || x < limits.left || + y > limits.bottom || y < limits.top) { + return; + } + pallet.view(x, y, false, pos.r); for (let f of body.fixtures) { diff --git a/public/static/js/wingbase/render/render.js b/public/static/js/wingbase/render/render.js index bbd5091..74f3d06 100644 --- a/public/static/js/wingbase/render/render.js +++ b/public/static/js/wingbase/render/render.js @@ -91,12 +91,13 @@ class Renderer { let gridy = cy % 50; let lastBlue = false; + let b = game.world.bounds; + this.pallet.opacity(0.05); for (var x = gridx - cw / 2 - 50; x < cw + 50; x += 50) { for (var y = gridy - ch / 2 - 50; y < ch + 50; y += 50) { var wx = ((-cx + x) / SCALE) | 0; var wy = ((-cy + y) / SCALE) | 0; - var b = game.world.bounds; if (wx > b.right || wx < b.left || wy > b.bottom || wy < b.top) { if (!lastBlue) { this.pallet.opacity(0.2);