From: dsc Date: Mon, 11 Apr 2011 08:32:40 +0000 (-0700) Subject: Removes remaining game logging. X-Git-Url: http://git.less.ly:3516/?a=commitdiff_plain;h=769969f2f47c901077d7b20e6356de1a8710679f;p=tanks.git Removes remaining game logging. --- diff --git a/src/tanks/thing/player.cjs b/src/tanks/thing/player.cjs index bbf2e07..4766cda 100644 --- a/src/tanks/thing/player.cjs +++ b/src/tanks/thing/player.cjs @@ -38,7 +38,6 @@ Tank.subclass('Player', { init : function initPlayer(align){ Tank.init.call(this, align); - this.gameLog = []; this.queue = []; this.activeKeys = new Y.YArray(); this.inventory = new Inventory(this); @@ -79,24 +78,10 @@ Tank.subclass('Player', { this.applyRecoilMove(); - var action; - if (this.replayMode) { - action = this.nextMove; - - if (!action || TICKS < action.ticks) - return this; - - // var drift = TICKS - action.ticks; - // if (drift) console.warn('replay drift: '+(drift > 0 ? '+' : '')+drift); - this.nextMove = this.replay.shift(); - - } else { - action = this.queue.shift(); - - if ( !action && this.activeKeys.size() ) { - var to = this.getPlayerMove(); - if (to) action = { 'type':'move', 'data':to }; - } + var action = this.queue.shift(); + if ( !action && this.activeKeys.size() ) { + var to = this.getPlayerMove(); + if (to) action = { 'type':'move', 'data':to }; } if ( !action ) { @@ -106,15 +91,8 @@ Tank.subclass('Player', { var data = action.data; switch (action.type) { - case 'shoot': - if (!this.replayMode && this.enableGameLogging) - this.gameLog.push({ 'type':'shoot', 'ticks':TICKS, 'data':data.toObject() }); - this.shoot(data.x, data.y); - break; - - case 'move': - this.move(data.x, data.y); - break; + case 'shoot': this.shoot(data.x, data.y); break; + case 'move': this.move(data.x, data.y); break; default: console.error('wtf unknown player action "'+action.type+'"', action); @@ -145,11 +123,7 @@ Tank.subclass('Player', { if (!dir) return; // @see Tank.move() - var to = this.loc.moveByDir(dir, this.stats.move.val * SQUARETH); - if (!this.replayMode && this.enableGameLogging) - this.gameLog.push({ 'type':'move', 'ticks':TICKS, 'data':to.toObject() }); - - return to; + return this.loc.moveByDir(dir, this.stats.move.val * SQUARETH); }, @@ -162,7 +136,7 @@ Tank.subclass('Player', { }, keydown : function keydown(evt){ - if ( !this.game.loop.running || this.replayMode ) return; + if ( !this.game.loop.running ) return; this.updateMeta(evt); @@ -189,7 +163,7 @@ Tank.subclass('Player', { }, mousedown : function mousedown(evt){ - if ( !this.game.loop.running || this.replayMode ) return; + if ( !this.game.loop.running ) return; switch (evt.which) { case 1: evt.leftMouse = true; @@ -226,7 +200,7 @@ Tank.subclass('Player', { }, mousemove : function mousemove(evt){ - if ( !this.game.loop.running || this.replayMode ) return; + if ( !this.game.loop.running ) return; this.rotateBarrelRelPage(evt.pageX, evt.pageY); } diff --git a/src/tanks/thing/unit.cjs b/src/tanks/thing/unit.cjs index 59ec2df..f56999f 100644 --- a/src/tanks/thing/unit.cjs +++ b/src/tanks/thing/unit.cjs @@ -53,19 +53,23 @@ Thing.subclass('Unit', { }, /** - * Fires this agent's cannon. If a target location is omitted, the shot - * will be fired in the direction of the tank's current barrel rotation. + * Fires this agent's cannon at a target location. * - * @param {Number} [x] Target X coordinate. - * @param {Number} [y] Target Y coordinate. + * @param {Number} x Target X coordinate. + * @param {Number} y Target Y coordinate. */ shoot : function shoot(x,y){ if ( !this.ableToShoot() ) return null; if (x instanceof Array) { y = x[_Y]; x = x[_X]; } - var xydef = (x !== undefined && y !== undefined); - if (xydef && this.hasBarrel) + + if (x === undefined || y === undefined) { + console.error('Unit.fire() without args!', this); + return null; + } + + if ( this.hasBarrel ) this.rotateBarrel(x,y); // Additional space on each side which must be clear around the @@ -85,25 +89,21 @@ Thing.subclass('Unit', { if ( blockers.size() ) return null; // console.log('squelch!', blockers); - if (!xydef && this.hasBarrel) { - var theta = this.getBarrelAngle() - , sin = Math.sin(theta), cos = Math.cos(theta); - x = tx + REF_SIZE*cos; - y = ty + REF_SIZE*sin; - } - this.cooldowns.attack.activate(this.now); this.nShots++; // Recoil // TODO: allow stacking recoil - var recoil_dist = this.stats.recoil.val * RECOIL_DIST_UNIT - , recoil_speed = recoil_dist / RECOIL_DURATION - ; - this.recoil.vec = new Vec(tx-x, ty-y); - this.recoil.remaining = RECOIL_DURATION; - this.recoil.speed = recoil_speed; - this.applyRecoilMove(); + var recoil_val = this.stats.recoil.val; + if (recoil_val) { + var recoil_dist = recoil_val * RECOIL_DIST_UNIT + , recoil_speed = recoil_dist / RECOIL_DURATION + ; + this.recoil.vec = new Vec(tx-x, ty-y); + this.recoil.remaining = RECOIL_DURATION; + this.recoil.speed = recoil_speed; + this.applyRecoilMove(); + } var p = new Projectile(this, tx,ty, x,y); p.on('destroy', this.onBulletDeath);