From: dsc Date: Mon, 17 Jan 2011 09:41:03 +0000 (-0800) Subject: Fixes direction of cooldown animation X-Git-Url: http://git.less.ly:3516/?a=commitdiff_plain;h=074eb4119876a0e8cd44f1ce5a1e485c7fb5b95c;p=tanks.git Fixes direction of cooldown animation --- diff --git a/data/types/items.yaml b/data/types/items.yaml index 90e0e87..9b2505e 100644 --- a/data/types/items.yaml +++ b/data/types/items.yaml @@ -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: diff --git a/src/ezl/index.cjs b/src/ezl/index.cjs index 112295b..bca3143 100644 --- a/src/ezl/index.cjs +++ b/src/ezl/index.cjs @@ -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 index 0000000..51f696d --- /dev/null +++ b/src/ezl/mixins/index.cjs @@ -0,0 +1,4 @@ +require('Y').Y.core +.extend(exports, { + 'Speciated' : require('ezl/mixins/speciated').Speciated +}); \ No newline at end of file diff --git a/src/tanks/mixins/speciated.cjs b/src/ezl/mixins/speciated.cjs similarity index 71% rename from src/tanks/mixins/speciated.cjs rename to src/ezl/mixins/speciated.cjs index c204417..13357f3 100644 --- a/src/tanks/mixins/speciated.cjs +++ b/src/ezl/mixins/speciated.cjs @@ -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; } diff --git a/src/ezl/util/data/datafile.cjs b/src/ezl/util/data/datafile.cjs index 699ddf4..093afb4 100644 --- a/src/ezl/util/data/datafile.cjs +++ b/src/ezl/util/data/datafile.cjs @@ -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)!'); diff --git a/src/ezl/widget/cooldown.cjs b/src/ezl/widget/cooldown.cjs index d7429a4..61e1c0b 100644 --- a/src/ezl/widget/cooldown.cjs +++ b/src/ezl/widget/cooldown.cjs @@ -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(); diff --git a/src/tanks/effects/buff.cjs b/src/tanks/effects/buff.cjs index 0841194..cd8b6e4 100644 --- a/src/tanks/effects/buff.cjs +++ b/src/tanks/effects/buff.cjs @@ -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 , diff --git a/src/tanks/game.cjs b/src/tanks/game.cjs index 08c7d0a..5fea328 100644 --- a/src/tanks/game.cjs +++ b/src/tanks/game.cjs @@ -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(); diff --git a/src/tanks/map/level.cjs b/src/tanks/map/level.cjs index 21944c9..1093e53 100644 --- a/src/tanks/map/level.cjs +++ b/src/tanks/map/level.cjs @@ -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) diff --git a/src/tanks/mixins/index.cjs b/src/tanks/mixins/index.cjs index ea351cc..efdab04 100644 --- a/src/tanks/mixins/index.cjs +++ b/src/tanks/mixins/index.cjs @@ -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 diff --git a/src/tanks/thing/thing.cjs b/src/tanks/thing/thing.cjs index e184dc3..1e4f577 100644 --- a/src/tanks/thing/thing.cjs +++ b/src/tanks/thing/thing.cjs @@ -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 , diff --git a/src/tanks/ui/inventory/backpack.cjs b/src/tanks/ui/inventory/backpack.cjs index 44be452..e62271c 100644 --- a/src/tanks/ui/inventory/backpack.cjs +++ b/src/tanks/ui/inventory/backpack.cjs @@ -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(); }, diff --git a/src/tanks/ui/main.cjs b/src/tanks/ui/main.cjs index d1994d6..a2fbafb 100644 --- a/src/tanks/ui/main.cjs +++ b/src/tanks/ui/main.cjs @@ -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