Fixes direction of cooldown animation
authordsc <david.schoonover@gmail.com>
Mon, 17 Jan 2011 09:41:03 +0000 (01:41 -0800)
committerdsc <david.schoonover@gmail.com>
Mon, 17 Jan 2011 09:41:03 +0000 (01:41 -0800)
13 files changed:
data/types/items.yaml
src/ezl/index.cjs
src/ezl/mixins/index.cjs [new file with mode: 0644]
src/ezl/mixins/speciated.cjs [moved from src/tanks/mixins/speciated.cjs with 71% similarity]
src/ezl/util/data/datafile.cjs
src/ezl/widget/cooldown.cjs
src/tanks/effects/buff.cjs
src/tanks/game.cjs
src/tanks/map/level.cjs
src/tanks/mixins/index.cjs
src/tanks/thing/thing.cjs
src/tanks/ui/inventory/backpack.cjs
src/tanks/ui/main.cjs

index 90e0e87..9b2505e 100644 (file)
@@ -7,9 +7,9 @@ types:
         desc: Speeds up your tank temporarily.
         tags: [ 'movement' ]
         passives: []
-        effects: [ 'speedup' ]
-        # effects:
-        #   - include: speedup
+        # effects: [ 'speedup' ]
+        effects:
+          - include: tanks/effects/buff.Buff:speedup
         cooldowns:
             activate: 30.0
         art:
index 112295b..bca3143 100644 (file)
@@ -8,6 +8,7 @@ var Y = require('Y').Y;
 Y.extend(exports, {
     'math'   : require('ezl/math'),
     'loc'    : require('ezl/loc'),
+    'mixins' : require('ezl/mixins'),
     'util'   : require('ezl/util'),
     
     'loop'   : require('ezl/loop'),
diff --git a/src/ezl/mixins/index.cjs b/src/ezl/mixins/index.cjs
new file mode 100644 (file)
index 0000000..51f696d
--- /dev/null
@@ -0,0 +1,4 @@
+require('Y').Y.core
+.extend(exports, {
+    'Speciated'   : require('ezl/mixins/speciated').Speciated
+});
\ No newline at end of file
similarity index 71%
rename from src/tanks/mixins/speciated.cjs
rename to src/ezl/mixins/speciated.cjs
index c204417..13357f3 100644 (file)
@@ -1,8 +1,46 @@
 var Y = require('Y').Y
+,   getNested = require('Y/types/object').getNested
 ,   deepcopy = require('Y/types/object').deepcopy
 ,   Mixin = require('evt').Mixin
 ,
 
+resolve =
+exports['resolve'] =
+function resolve(spec){
+    var idx = spec.indexOf('.')
+    ,   modName = spec.slice(0, idx !== -1 ? idx : spec.length)
+    ,   objName = spec.slice(idx+1)
+    ,   module, speciesName, symbol ;
+    
+    if (idx === 0) {
+        module = window;
+        objName = spec.slice(1);
+    } else
+        module = require(modName);
+    
+    idx = objName.indexOf(':');
+    if (idx !== -1) {
+        speciesName = objName.slice(idx+1);
+        objName = objName.slice(0, idx);
+    }
+    
+    if (!objName)
+        this.die('Cannot resolve symbol: '+spec);
+    
+    symbol = getNested(module, objName)
+    if (!symbol)
+        this.die('Unable to locate class specified by symbol (symbol="'+spec+'", module='+module+', object="'+objName+'" --> '+symbol+')!');
+    
+    if (speciesName) {
+        symbol = symbol.lookup(speciesName);
+        if (!symbol) this.die('Unable to locate species specified by symbol (symbol="'+spec+'", module='+module+', object="'+objName+'", species="'+speciesName+'" --> '+symbol+')!');
+    }
+    
+    return symbol;
+}
+,
+
+
 Speciated =
 exports['Speciated'] =
 Mixin.subclass('Speciated', {
@@ -44,7 +82,7 @@ Mixin.subclass('Speciated', {
             props.__species__ = id;
             
             if (props.include) {
-                var parent = this.lookup(props.inherit);
+                var parent = resolve(props.include);
                 props = deepcopy(Y.extend({}, parent.__species_props__, props));
                 delete props.include;
             }
index 699ddf4..093afb4 100644 (file)
@@ -3,6 +3,7 @@ var Y = require('Y').Y
 ,   evt = require('evt')
 ,   getNested = require('Y/types/object').getNested
 ,   deepcopy = require('Y/types/object').deepcopy
+,   resolve = require('ezl/mixins/speciated').resolve
 ,
 
 
@@ -25,26 +26,6 @@ new evt.Class('DataFile', {
         return this;
     },
     
-    resolve : function resolve(spec){
-        var nameParts = spec.split('.')
-        ,   modName = nameParts.shift()
-        ,   module ;
-        
-        if (!modName)
-            module = window;
-        else
-            module = require(modName);
-        
-        if (!nameParts.length)
-            this.die('Cannot resolve symbol: '+spec);
-        
-        var symbol = getNested(module, nameParts)
-        if (!symbol)
-            this.die('Unable to locate class specified by symbol (symbol="'+spec+'", module='+module+' --> '+symbol+')!');
-        
-        return symbol;
-    },
-    
     process : function process(data){
         this.data = data;
         this.fire('process', data);
@@ -64,7 +45,7 @@ new evt.Class('DataFile', {
                 this.die('No symbol defined for type "'+id+'" at '+this.path+'!');
             
             delete props.symbol;
-            var base = this.resolve(symbol);
+            var base = resolve(symbol);
             
             if (!Y.isFunction(base.speciate))
                 this.die('Cannot create types from data (symbol-class '+base+' from "'+symbol+'" is not Speciated)!');
index d7429a4..61e1c0b 100644 (file)
@@ -46,9 +46,9 @@ Layer.subclass('CooldownGauge', function setupCooldownGauge(CooldownGauge){
         var p = cool.ratio()
         ,   w = this.layerWidth, h = this.layerHeight
         ,   x = w*0.5, y = h*0.5
-        ,   amt = -HALF_PI + (1 - p)*TWO_PI;
+        ,   amt = p*TWO_PI - HALF_PI;
         
-        ctx.arc(x,y, w, -HALF_PI, amt, false);
+        ctx.arc(x,y, w, -HALF_PI, amt, true);
         ctx.lineTo(x,y);
         ctx.lineTo(x,0);
         ctx.fill();
index 0841194..cd8b6e4 100644 (file)
@@ -2,7 +2,7 @@ var Y = require('Y').Y
 ,   evt = require('evt')
 ,   mul = Y.op.curried.mul
 
-,   Speciated  = require('tanks/mixins/speciated').Speciated
+,   Speciated  = require('ezl/mixins/speciated').Speciated
 ,   Meronomic  = require('tanks/mixins/meronomic').Meronomic
 ,   Quantified = require('tanks/mixins/quantified').Quantified
 ,
index 08c7d0a..5fea328 100644 (file)
@@ -48,19 +48,15 @@ Y.subclass('Game', {
         this.bullets    = new Y.YArray();
         this.animations = new Y.YArray();
         
-        // this.el = $(GAME_ELEMENT);
         this.loop = new EventLoop(FRAME_RATE, this);
         
         this.root =
             new Layer({ hasCanvas:false }, { 'id':'game' })
                 .prependTo( $('body') );
-        // this.root.shape.remove();
-        // this.root.layer.attr('id', 'viewport');
         
         this.viewport = 
             new Layer({ hasCanvas:false }, { 'id':'viewport' })
                 .appendTo( this.root );
-        
         this.level =
             Level.create(this.levelId, this, CAPACITY, REF_SIZE)
                 .appendTo( this.viewport );
@@ -98,7 +94,6 @@ Y.subclass('Game', {
         Thing.removeEventListener('created', this.addUnit);
         Thing.removeEventListener('destroy', this.killUnit);
         this.root.remove();
-        // this.backpack && this.backpack.remove();
         this.stop();
         this.resetGlobals();
     },
@@ -111,9 +106,6 @@ Y.subclass('Game', {
         SQUARETH = REF_SIZE * SECONDTH;
     },
     
-    // get width(){ return this.level.width; },
-    // get height(){ return this.level.height; },
-    
     draw : function draw(){
         this.root.draw();
         // this.backpack.draw();
index 21944c9..1093e53 100644 (file)
@@ -11,7 +11,7 @@ var Y          = require('Y').Y
 ,   Item       = require('tanks/thing/item').Item
 ,   Player = require('tanks/thing/player').Player
 ,   Wall       = require('tanks/map/wall').Wall
-,   Speciated  = require('tanks/mixins/speciated').Speciated
+,   Speciated  = require('ezl/mixins/speciated').Speciated
 
 ,   min = Y(Math.min).limit(2)
 ,   max = Y(Math.max).limit(2)
index ea351cc..efdab04 100644 (file)
@@ -1,6 +1,5 @@
 require('Y').Y.core
 .extend(exports, {
-    'Speciated'   : require('tanks/mixins/speciated').Speciated,
     'Meronomic'   : require('tanks/mixins/meronomic').Meronomic,
     'Quantified'  : require('tanks/mixins/quantified').Quantified,
     'Inventoried' : require('tanks/mixins/inventoried').Inventoried
index e184dc3..1e4f577 100644 (file)
@@ -14,7 +14,7 @@ var Y           = require('Y').Y
 ,   DensityType = constants.DensityType
 ,   stat        = require('tanks/effects/stat')
 ,   Quantified  = require('tanks/mixins/quantified').Quantified
-,   Speciated   = require('tanks/mixins/speciated').Speciated
+,   Speciated   = require('ezl/mixins/speciated').Speciated
 ,
 
 
index 44be452..e62271c 100644 (file)
@@ -102,7 +102,6 @@ Layer.subclass('BackpackSlot', {
         this.layer.bind('click', this.onActivate);
         
         this.inner.append(item.activateGauge);
-        // item.activateGauge.draw();
         
         return this;
     },
@@ -117,7 +116,7 @@ Layer.subclass('BackpackSlot', {
     },
     
     onActivate : function onActivate(evt){
-        console.log(this+'.onActivate()!');
+        // console.log(this+'.onActivate()!');
         this.item.activate();
     },
     
index d1994d6..a2fbafb 100644 (file)
@@ -25,6 +25,8 @@ function stopProp(evt){ evt.stopPropagation(); }
 qkv = Y(window.location.search.slice(1)).fromKV();
 hkv = Y(window.location.hash.slice(1)).fromKV();
 
+
+
 // Main method is only executed once, so we'll setup things
 // that don't change between games.
 function main(){
@@ -201,8 +203,8 @@ gameover = Y(gameover).curry();
 
 function countdown(n, fn){
     var el
-    ,   showFor  = 750
-    ,   pauseFor = 500
+    ,   showFor  = 550
+    ,   pauseFor = 400
     
     ,   body = $('body')
     ,   sizeRatio = 0.6