reduce physics cpu usage

This commit is contained in:
Asraelite 2016-03-29 22:35:08 +01:00
parent 8a059b92d5
commit 8ea6c2d937
10 changed files with 2435 additions and 34 deletions

View file

@ -23,6 +23,7 @@ class Net {
this.socket.on('world', data => {
game.world.clear();
console.log(data);
game.world.bounds = data.bounds;
for (var b of data.bodies) {
game.world.add(b);

View file

@ -77,8 +77,8 @@ class Renderer {
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;
var wy = (-cy + y) / SCALE;
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) {
this.pallet.opacity(0.2);