clean client code
This commit is contained in:
parent
f3619ba891
commit
21a30ad212
18 changed files with 294 additions and 268 deletions
|
@ -66,6 +66,7 @@ class Room {
|
|||
sendWorld(player) {
|
||||
let data = {
|
||||
playerShipId: player.ship.id,
|
||||
bounds: this.world.bounds,
|
||||
bodies: Array.from(this.world.bodies).map(b => b.packFull())
|
||||
};
|
||||
|
||||
|
|
|
@ -33,10 +33,10 @@ class Body {
|
|||
let pos = this.b2body.GetPosition();
|
||||
let bounds = this.world.bounds;
|
||||
|
||||
if(pos.x < bounds.left) this.applyForce(0.003, 0);
|
||||
if(pos.x > bounds.right) this.applyForce(-0.003, 0);
|
||||
if(pos.y < bounds.top) this.applyForce(0, 0.003);
|
||||
if(pos.y > bounds.bottom) this.applyForce(-0, -0.003);
|
||||
if(pos.x < bounds.left) this.applyForce(0.03, 0);
|
||||
if(pos.x > bounds.right) this.applyForce(-0.03, 0);
|
||||
if(pos.y < bounds.top) this.applyForce(0, 0.03);
|
||||
if(pos.y > bounds.bottom) this.applyForce(-0, -0.03);
|
||||
}
|
||||
|
||||
packDelta() {
|
||||
|
|
|
@ -66,7 +66,6 @@ class Physics {
|
|||
|
||||
step() {
|
||||
this.world.Step(1, 5, 1 / 60);
|
||||
|
||||
for (var i = 0; i < this.toRemove.length; i++) {
|
||||
this.world.DestroyBody(this.toRemove[i].b2body);
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
'use strict';
|
||||
|
||||
const colors = require('colors');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
@ -9,13 +11,25 @@ function minifyJs(callback) {
|
|||
|
||||
var dir = path.join(__dirname, '../../public/js/starbugs');
|
||||
var cache = '';
|
||||
var scripts = [];
|
||||
|
||||
var getPriority = (file) => {
|
||||
if (file.slice(0, 3) == '//@') {
|
||||
let a = +file.split('\n')[0].slice(3);
|
||||
return a;
|
||||
} else return 0;
|
||||
}
|
||||
|
||||
recursive(dir, function(err, files) {
|
||||
for(var i in files) {
|
||||
cache += fs.readFileSync(files[i], 'utf8').toString();
|
||||
scripts.push(fs.readFileSync(files[i], 'utf8').toString());
|
||||
}
|
||||
|
||||
var comment = '';
|
||||
scripts.sort((a, b) => getPriority(b) - getPriority(a));
|
||||
|
||||
let comment = '';
|
||||
|
||||
cache = scripts.join('');
|
||||
|
||||
// Remove to re-enable minifying.
|
||||
callback(cache); return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue