Activates attack cooldown.
authordsc <david.schoonover@gmail.com>
Thu, 18 Nov 2010 02:59:49 +0000 (18:59 -0800)
committerdsc <david.schoonover@gmail.com>
Thu, 18 Nov 2010 02:59:49 +0000 (18:59 -0800)
src/tanks/thing/thing.js
src/tanks/ui/player.js

index 20eb553..776d64d 100644 (file)
@@ -128,9 +128,6 @@ Thing = new Evt.Class('Thing', {
         else
             this.move();
         
-        if (bb.x1 <= MIN_X_DIST || bb.x2 >= MAX_X_DIST)
-            this.destroy();
-        
         return this;
     },
     
index 3f90adf..7d011a7 100644 (file)
@@ -57,6 +57,8 @@ Player = new Y.Class('Player', {
         if (this.tank.dead)
             return this.tank;
         
+        this.tank.cooldowns.invoke('update', NOW);
+        
         var action = this.queue.shift();
         
         if (action && action.type === 'fire') {
@@ -70,9 +72,14 @@ Player = new Y.Class('Player', {
     
     fire : function fire(){
         var WIGGLE = 4
+        ,   tank   = this.tank
+        ,   cooldown = tank.cooldowns.attr('attack')
+        ;
+        
+        if ( !cooldown.activate(NOW) )
+            return;
         
-        ,   tank = this.tank
-        ,   barrel = tank.barrel
+        var barrel = tank.barrel
         ,   bb = tank.boundingBox
         ,   w2 = bb.width/2,    h2 = bb.height/2
         ,   x0 = bb.x1+w2,      y0 = bb.y1+h2