diff --git a/public/static/js/wingbase/world/body.js b/public/static/js/wingbase/world/body.js index bf2d501..61dcb1b 100644 --- a/public/static/js/wingbase/world/body.js +++ b/public/static/js/wingbase/world/body.js @@ -11,8 +11,8 @@ class Body { this.fixtures = data.fixtures; this.b2body = false; this.updated = 0; - - game.world.update(data.delta); + + this.update(data.delta.slice(1)); this.com = { x: 0, diff --git a/public/static/js/wingbase/world/world.js b/public/static/js/wingbase/world/world.js index fc5dfa4..50059f6 100644 --- a/public/static/js/wingbase/world/world.js +++ b/public/static/js/wingbase/world/world.js @@ -44,10 +44,9 @@ class World { }; update(data) { - let array = new Float32Array(data); let i = 0; - while (i < array.length) { - let id = array[i++]; + while (i < data.length) { + let id = data[i++]; let body = this.bodies[id]; if (!body) { @@ -55,7 +54,7 @@ class World { return; } - body.update(array.slice(i, i + body.interface.size)); + body.update(data.slice(i, i + body.interface.size)); i += body.interface.size; } }; diff --git a/server/game/room/world/body/body.js b/server/game/room/world/body/body.js index 264fae4..21d1f2b 100644 --- a/server/game/room/world/body/body.js +++ b/server/game/room/world/body/body.js @@ -14,6 +14,13 @@ class Body { this.type = 'body'; this.b2body = false; + this.x = data.x || 0; + this.y = data.y || 0; + this.xvel = data.xvel || 0; + this.yvel = data.yvel || 0; + this.r = data.r || 0; + this.rvel = data.rvel || 0; + this.mounts = data.mounts || []; this.health = data.health || 1; this.mounts = this.mounts.map(m => new Mount(this, m)); @@ -113,7 +120,7 @@ class Body { fixtures: this.mounts.map(m => m.packFull()), delta: this.packDelta(), interface: this.interface - } + }; let typePacket = this.packTypeFull(); for (let i in typePacket) diff --git a/server/game/room/world/body/projectile/grapple.js b/server/game/room/world/body/projectile/grapple.js index a91d222..027902c 100644 --- a/server/game/room/world/body/projectile/grapple.js +++ b/server/game/room/world/body/projectile/grapple.js @@ -5,9 +5,11 @@ const Rope = require('../../copula/rope.js'); class Grapple extends Projectile { constructor(world, pos, source) { - // pos.x *= 32, pos.y *= 32, idk why super(world, pos); + this.r = pos.r; + this.x = pos.x * 32; + this.y = pos.y * 32; this.xvel += Math.cos(this.r) * 0.25; this.yvel += Math.sin(this.r) * 0.25; diff --git a/server/game/room/world/body/projectile/projectile.js b/server/game/room/world/body/projectile/projectile.js index 12b0500..ab6c192 100644 --- a/server/game/room/world/body/projectile/projectile.js +++ b/server/game/room/world/body/projectile/projectile.js @@ -5,6 +5,8 @@ const Body = require('../body.js'); class Projectile extends Body { constructor(world) { super(world); + + this.class = 'projectile'; } connect() { diff --git a/server/game/room/world/index.js b/server/game/room/world/index.js index 641764e..3b002de 100644 --- a/server/game/room/world/index.js +++ b/server/game/room/world/index.js @@ -75,6 +75,7 @@ class World { this.bodies.add(body); if (body.type == 'asteroid') this.asteroids.add(body); if (body.type == 'structure') this.structures.add(body); + if (body.class == 'projectile') this.projectiles.add(body); this.physics.createBody(body); this.room.broadcast('create', body.packFull()); } diff --git a/server/game/room/world/spawner.js b/server/game/room/world/spawner.js index 712143b..731db72 100644 --- a/server/game/room/world/spawner.js +++ b/server/game/room/world/spawner.js @@ -30,6 +30,7 @@ class Spawner { yvel: ship.vel.y }; let missile = new Missile(this.world, pos, ship); + this.world.addProjectile(missile); return missile; }