From 9667f0bfc319a3aeadd231d9226fb9570ae85bfd Mon Sep 17 00:00:00 2001 From: dsc Date: Sat, 1 Jan 2011 17:06:50 -0800 Subject: [PATCH] Found bullet-speed bug. Descriptors were not being copied correctly, so I suppose this means core.descriptors() is busted. --- src/Y/class.cjs | 5 ++++- src/Y/types/object.cjs | 4 ++-- src/Y/utils.cjs | 2 +- src/evt.cjs | 44 +++++++++++++++++++++++--------------------- src/tanks/effects/buff.cjs | 22 +++++++++++++++------- src/tanks/effects/stat.cjs | 3 ++- src/tanks/globals.js | 2 +- src/tanks/map/level.cjs | 33 +++++++++++++++++++++++++++++---- src/tanks/thing/item.cjs | 4 ++++ src/tanks/thing/player.cjs | 12 ++++++------ src/tanks/thing/tank.cjs | 2 +- src/tanks/thing/thing.cjs | 17 ++++++++++------- www/deps.html | 5 +++-- 13 files changed, 101 insertions(+), 54 deletions(-) diff --git a/src/Y/class.cjs b/src/Y/class.cjs index 683f032..b8bf9e9 100644 --- a/src/Y/class.cjs +++ b/src/Y/class.cjs @@ -22,6 +22,7 @@ var type = require('Y/type') , KNOWN_CLASSES = type.type.KNOWN_CLASSES , classToString = function toString(){ return this.className+"()"; } +, classStatics = [ 'instantiate', 'fabricate', 'subclass' ] ; /** @@ -107,8 +108,10 @@ function Class(className, Parent, members) { eval(constructor); // Copy Class statics - for (var k in ClassFactory) + for (var i=0, L=classStatics.length; i').appendTo('body'); + E = game.addThing(new Thing(2), 0,0); + var i = 0; + function testBulletSpeed(){ + B = P.shoot(0,475); + var start = new Date().getTime() + , startClock = NOW + , startX = B.loc.x; + B.bounces = 1; + console.log(i+' B.movePerMs='+B.movePerMs+', move='+B.stats.move); + + B.addEventListener('destroy', function(evt){ + var elapsed = (new Date().getTime() - start)/1000 + , clock = (NOW - startClock)/1000 + , distance = startX - B.loc.x ; + DATA.text(DATA.text()+elapsed.toFixed(3)+'\t'+clock.toFixed(3)+'\t'+distance.toFixed(3)+'\t'+(distance/elapsed).toFixed(3)+'\n'); + if (++i < 20) testBulletSpeed(); + }); + } + game.addEventListener('start', function(evt){ + DATA.text('elapsed\tclock\tpx\tpx/s\n'); + testBulletSpeed(); + }); }, addWall : function addWall(x,y, w,h, isBoundary){ diff --git a/src/tanks/thing/item.cjs b/src/tanks/thing/item.cjs index 59da3b9..6055a4f 100644 --- a/src/tanks/thing/item.cjs +++ b/src/tanks/thing/item.cjs @@ -57,6 +57,10 @@ Thing.subclass('Item', { this.addEventListener('collide', this.onCollide.bind(this)); }, + tick : function tick(elapsed, now){ + + }, + activate : function activate(){ if (!this.owner) return; }, diff --git a/src/tanks/thing/player.cjs b/src/tanks/thing/player.cjs index 859f2eb..f81c604 100644 --- a/src/tanks/thing/player.cjs +++ b/src/tanks/thing/player.cjs @@ -148,9 +148,9 @@ Tank.subclass('PlayerTank', { } this.updateMeta(evt); - if (window.getSelection) { - window.getSelection().removeAllRanges(); - } + // if (window.getSelection) { + // window.getSelection().removeAllRanges(); + // } return false; }, @@ -165,9 +165,9 @@ Tank.subclass('PlayerTank', { } this.updateMeta(evt); - if (window.getSelection) { - window.getSelection().removeAllRanges(); - } + // if (window.getSelection) { + // window.getSelection().removeAllRanges(); + // } return false; }, diff --git a/src/tanks/thing/tank.cjs b/src/tanks/thing/tank.cjs index d2d4163..bc9199d 100644 --- a/src/tanks/thing/tank.cjs +++ b/src/tanks/thing/tank.cjs @@ -38,7 +38,7 @@ Thing.subclass('Tank', function(Tank){ // Attributes stats : { - hp : 1, // health + hp : 2, // health move : 0.75, // move speed (squares/sec) rotate : HALF_PI, // rotation speed (radians/sec) power : 1, // attack power diff --git a/src/tanks/thing/thing.cjs b/src/tanks/thing/thing.cjs index e4c4525..b82b7d0 100644 --- a/src/tanks/thing/thing.cjs +++ b/src/tanks/thing/thing.cjs @@ -93,8 +93,11 @@ exports['Thing'] = new evt.Class('Thing', { 'attr' : op.attr.methodize(), get movePerMs(){ - var stat = this.stats.move; - return (typeof stat === "number" ? stat : stat.val)*REF_SIZE/1000; + var stat = this.stats.move + , move = (typeof stat === "number" ? stat : stat.val); + var r = move*REF_SIZE/1000; + console.log(this+'.movePerMs = '+move+'*'+REF_SIZE+'/1000 = '+r); + return r; }, @@ -122,15 +125,15 @@ exports['Thing'] = new evt.Class('Thing', { }, createCooldowns : function createCooldowns(){ - this.cooldowns = { + this._cooldowns = Y({ 'attack': new Cooldown(1000 * this.stats.speed.val) - }; - this.ai = Y(this.ai).map(function(freq, k){ + }); + this._ai = Y(this.ai).map(function(freq, k){ return new Cooldown(1000 * freq); }); - this._cooldowns = Y(this.cooldowns); - this._ai = Y(this.ai); + this.cooldowns = this._cooldowns.end(); + this.ai = this._ai.end(); }, updateCooldowns : function updateCooldowns(elapsed, now){ diff --git a/www/deps.html b/www/deps.html index f1ca947..a8d24b2 100644 --- a/www/deps.html +++ b/www/deps.html @@ -24,8 +24,8 @@ - + @@ -45,11 +45,12 @@ - + + -- 1.7.0.4