Adds properties for reflectivity and inventory; fills in Item collision code.
authordsc <david.schoonover@gmail.com>
Fri, 24 Dec 2010 19:52:34 +0000 (11:52 -0800)
committerdsc <david.schoonover@gmail.com>
Fri, 24 Dec 2010 19:52:34 +0000 (11:52 -0800)
26 files changed:
src/ezl/index.cjs
src/ezl/layer/html.cjs [copied from src/tanks/abilities/buff.cjs with 100% similarity]
src/ezl/layer/index.cjs [copied from src/tanks/abilities/index.cjs with 100% similarity]
src/ezl/layer/layer.cjs [moved from src/ezl/layer.cjs with 98% similarity]
src/ezl/layer/text.cjs [copied from src/tanks/abilities/buff.cjs with 100% similarity]
src/ezl/shape/circle.cjs
src/ezl/shape/line.cjs
src/ezl/shape/shape.cjs
src/ezl/util/astar.cjs
src/ezl/util/tree/binaryheap.cjs [moved from src/ezl/util/binaryheap.cjs with 100% similarity]
src/ezl/widget/cooldown.cjs
src/tanks/calc.cjs [deleted file]
src/tanks/effects/buff.cjs [moved from src/tanks/abilities/buff.cjs with 100% similarity]
src/tanks/effects/index.cjs [moved from src/tanks/abilities/index.cjs with 100% similarity]
src/tanks/map/level.cjs
src/tanks/map/pathmap.cjs
src/tanks/map/traversal.cjs
src/tanks/thing/bullet.cjs
src/tanks/thing/item.cjs
src/tanks/thing/player.cjs
src/tanks/thing/tank.cjs
src/tanks/thing/thing.cjs
src/tanks/thing/wall.cjs
src/tanks/ui/pathmapui.cjs
www/css/lttl.css
www/deps.html

index 0b952af..112295b 100644 (file)
@@ -6,12 +6,13 @@
 var Y = require('Y').Y;
 
 Y.extend(exports, {
-    'Layer'  : require('ezl/layer').Layer,
-    
+    'math'   : require('ezl/math'),
     'loc'    : require('ezl/loc'),
+    'util'   : require('ezl/util'),
+    
     'loop'   : require('ezl/loop'),
-    'math'   : require('ezl/math'),
+    
+    'layer'  : require('ezl/layer'),
     'shape'  : require('ezl/shape'),
-    'util'   : require('ezl/util'),
     'widget' : require('ezl/widget')
 });
similarity index 98%
rename from src/ezl/layer.cjs
rename to src/ezl/layer/layer.cjs
index 21f150f..75d5408 100644 (file)
@@ -1,16 +1,14 @@
 //#ensure "jquery"
-
-var undefined
-,   Y   = require('Y').Y
-,   Vec = require('ezl/math/vec').Vec
-,   loc = require('ezl/loc')
-,   Loc = loc.Loc
-,   BoundingBox = loc.BoundingBox
-,   Animation = require('ezl/loop/fx').Animation
+var Y           = require('Y').Y
+,   Vec         = require('ezl/math/vec').Vec
+,   Loc         = require('ezl/loc/loc').Loc
+,   BoundingBox = require('ezl/loc/boundingbox').BoundingBox
+,   Animation   = require('ezl/loop/fx').Animation
 , 
+
 CONTEXT_ATTRS  = Y('globalAlpha globalCompositeOperation strokeStyle fillStyle lineWidth lineCap lineJoin miterLimit shadowOffsetX shadowOffsetY shadowBlur shadowColor'.split(' ')),
 FAUX_ACCESSORS = Y('width height position stroke fill origin rotate scale translate title'.split(' '))
-,_X = 0, _Y = 1
+, _X = 0, _Y = 1
 ,
 
 
index 733148a..909ee8d 100644 (file)
@@ -1,5 +1,4 @@
-var Y = require('Y').Y
-,   Shape = require('ezl/shape/shape').Shape
+var Shape = require('ezl/shape/shape').Shape
 ,
 
 Circle =
index e007377..d347c7a 100644 (file)
@@ -2,7 +2,7 @@
 
 var Y     = require('Y').Y
 ,   math  = require('ezl/math')
-,   Layer = require('ezl/layer').Layer
+,   Layer = require('ezl/layer/layer').Layer
 ,   Shape = require('ezl/shape/shape').Shape
 ,
 
index 9e84fcc..e7ffad7 100644 (file)
@@ -1,5 +1,4 @@
-var Y = require('Y').Y
-,   Layer = require('ezl/layer').Layer
+var Layer = require('ezl/layer/layer').Layer
 ,
 
 Shape =
index 08e9885..1d15f05 100644 (file)
@@ -16,7 +16,7 @@
         var end = graph.nodes[1][2];
         astar.search(graph.nodes, start, end);
 */
-var BinaryHeap = require('ezl/util/binaryheap').BinaryHeap;
+var BinaryHeap = require('ezl/util/tree/binaryheap').BinaryHeap;
 
 exports['init'] = init;
 function init(grid) {
index c7f492a..e94b51b 100644 (file)
@@ -1,5 +1,5 @@
 var Y = require('Y').Y
-,   Layer = require('ezl/layer').Layer
+,   Layer = require('ezl/layer/layer').Layer
 
 ,   PI             = Math.PI
 ,   QUARTER_PI     = PI/4
diff --git a/src/tanks/calc.cjs b/src/tanks/calc.cjs
deleted file mode 100644 (file)
index 7e14ba2..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-Calc = {
-    
-    
-    
-};
\ No newline at end of file
index 6736b4f..147a7a1 100644 (file)
@@ -46,7 +46,7 @@ Rect.subclass('Level', {
         // game.addThing(new Tank(2), 1,0);
         // game.addThing(new Tank(2), 8,1);
         
-        // I = game.addThing(new Item(), 8,8);
+        I = game.addThing(new Item(), 8,8);
     },
     
     addWall : function addWall(x,y, w,h, isBoundary){
index 623cc21..c82075b 100644 (file)
@@ -4,7 +4,7 @@ var Y          = require('Y').Y
 ,   math       = require('ezl/math')
 ,   vec        = require('ezl/math/vec')
 ,   QuadTree   = require('ezl/util/tree/quadtree').QuadTree
-,   BinaryHeap = require('ezl/util/binaryheap').BinaryHeap
+,   BinaryHeap = require('ezl/util/tree/binaryheap').BinaryHeap
 ,   Vec        = vec.Vec
 ,   Line       = math.Line
 
index 4316d32..c51d193 100644 (file)
@@ -110,11 +110,10 @@ Y.subclass('Traversal', {
     },
     
     collide : function collide(blocker){
-        var thing = this.thing
-        ,   data  = { 'traversal':this, 'thing':thing, 'blocker':blocker };
+        var thing = this.thing;
         
-        thing.fire('collide', blocker, data);
-        blocker.fire('collide', thing, data);
+        thing.fire('collide', blocker, { 'traversal':this, 'unit':blocker });
+        blocker.fire('collide', thing, { 'traversal':this, 'unit':thing });
     },
     
     rewind : function rewind(blocker){
index b2a7e9c..22a02cc 100644 (file)
@@ -115,11 +115,11 @@ Thing.subclass('Bullet', {
         var traj = this.trajectory
         
         ,   ng, d = evt.data
+        ,   unit = d.unit
         ,   tvsl = d.traversal
         ,   to   = tvsl.to
-        ,   unit = d.blocker
         
-        ,   isReflective = unit instanceof Wall // XXX: unit.reflective
+        ,   isReflective = unit.isReflective
         ;
         
         // Ignore collisions with zones
index 704708a..231baef 100644 (file)
@@ -7,39 +7,84 @@ var Y     = require('Y').Y
 ,   map   = require('tanks/map/map')
 ,   Thing = require('tanks/thing/thing').Thing
 
-,   SIZE = REF_SIZE * 0.5
+,   ITEM_SIZE = REF_SIZE * 0.5
 ,
 
 
 Item =
 exports['Item'] =
 Thing.subclass('Item', {
-    blocking : map.ZONE,
-    active   : false,
+    align : 0, // 0 reserved for neutral units
     
-    width  : SIZE,
-    height : SIZE,
+    blocking : map.ZONE,
+    width    : ITEM_SIZE,
+    height   : ITEM_SIZE,
     
-    stats : { hp:1, move:0, power:0 },
+    // indestructable
+    stats      : { hp:Infinity, move:0, power:0 },
+    dealDamage : op.nop,
     
     // inactive
-    createCooldowns : op.nop,
-    updateCooldowns : op.nop,
-    act : op.nop,
+    active     : false,
+    
+    
+    /// Instance Properties ///
+    type     : 'dummy',     // {String} Item type identifier (unique, for config lookup)
+    name     : 'Dummy',     // {String} Display name
+    icon_inv : '',          // {String} URL to inventory icon file (TODO)
+    icon_map : '',          // {String} URL to map icon file (TODO)
+    buffs    : Y([]),       // {Buff...} Passive effects (triggered on pickup)
+    effects  : Y([]),       // {Function...} Active effects (triggered on activation)
+    owner    : null,        // {Unit} Owner when picked up.
     
-    // indestructable
-    dealDamage : op.nop,
     
     
-    init : function initItem(){
+    // XXX: Setting these per-instance only while testing
+    init : function initItem(name, buffs, effects){
         Thing.init.call(this, 0);
+        if (name) this.name = name;
+        
+        if (buffs)
+            this.buffs = Y(buffs);
+        else
+            this.buffs = this.buffs.clone();
+        
+        if (effects)
+            this.effects = Y(effects);
+        else
+            this.effects = this.effects.clone();
         
         this.addEventListener('collide', this.onCollide.bind(this));
     },
     
+    activate : function activate(){
+        if (!this.owner) return;
+    },
+    
+    acquired : function acquired(unit){
+        this.owner = unit;
+        console.log(unit+' acquired '+this+'!');
+        // TODO: apply buffs
+        unit.fire('acquire', this, { 'unit':unit, 'item':this });