Adds tank colors to unit config.
authordsc <david.schoonover@gmail.com>
Tue, 4 Jan 2011 11:45:01 +0000 (03:45 -0800)
committerdsc <david.schoonover@gmail.com>
Tue, 4 Jan 2011 11:45:01 +0000 (03:45 -0800)
data/types/units.yaml
data/types/weapons.yaml [new file with mode: 0644]
src/tanks/map/level.cjs
src/tanks/thing/player.cjs
src/tanks/thing/tank.cjs

index f62f730..331bc54 100644 (file)
@@ -14,12 +14,12 @@ defaults:
     cooldowns:
         attack: stats.move.val
     ai:
-        path          : 1.0         # calculate a path to enemy
-        dodge         : 1.0         # dodge an incoming bullet
-        shootIncoming : 0.5         # shoot down incoming bullet
+        path          : 1.00        # calculate a path to enemy
+        dodge         : 1.00        # dodge an incoming bullet
+        shootIncoming : 0.25        # shoot down incoming bullet
         shootEnemy    : 0.75        # shoot at enemy tank if in range
     art:
-        icon: ''
+        map_icon: ''
         inv_icon: ''
 types:
     player:
@@ -28,14 +28,38 @@ types:
         tags: [ 'tank' ]
         symbol: tanks/thing/player.PlayerTank
         stats:
-            hp    : 10
+            hp    : 1
             move  : 0.90
             power : 1
             speed : 0.5
             shots : 5
-    pink:
-        name: Pink Tank
-        desc: A very pink tank.
+        colors:
+            body   : '#E73075'
+            turret : '#A72F5B'
+            barrel : '#2E62C9'
+    blue:
+        name: Blue Tank
+        desc: A friendly blue tank.
+        tags: [ 'tank' ]
+        symbol: tanks/thing/tank.Tank
+        stats:
+            hp    : 1
+            move  : 0.75
+            power : 1
+            speed : 0.5
+            shots : 3
+        ai:
+            path          : 1.0
+            dodge         : 1.0
+            shootIncoming : 0.25
+            shootEnemy    : 0.75
+        colors:
+            body   : '#4596FF'
+            turret : '#182B53'
+            barrel : '#F25522'
+    green:
+        name: Green Tank
+        desc: A very green tank.
         tags: [ 'tank' ]
         symbol: tanks/thing/tank.Tank
         stats:
@@ -43,11 +67,16 @@ types:
             move  : 0.75
             power : 1
             speed : 0.5
-            shots : 4
+            shots : 3
         ai:
             path          : 1.0
             dodge         : 1.0
-            shootIncoming : 0.5
+            shootIncoming : 0.25
             shootEnemy    : 0.75
+        colors:
+            body   : '#83BB32'
+            turret : '#1C625B'
+            barrel : '#D43B24'
+            
         
     
diff --git a/data/types/weapons.yaml b/data/types/weapons.yaml
new file mode 100644 (file)
index 0000000..e69de29
index e5f56e9..08f1c68 100644 (file)
@@ -42,17 +42,16 @@ Rect.subclass('Level', {
             this );
         
         P =
-        game.player = game.addThing(PlayerTank.create('player', 1), 3,9);
-        // game.addThing(Tank.create('blue', 1).colors('#4596FF', '#182B53', '#F25522'), 3,9);
+        game.player = game.addThing(PlayerTank.create('player', 1), 5,9);
+        game.addThing(Tank.create('blue', 1), 3,9);
         
-        E1 =
-        game.addThing(Tank.create('pink', 2), 0,7);
-        E2 =
-        game.addThing(Tank.create('pink', 2), 1,0);
-        E3 =
-        game.addThing(Tank.create('pink', 2), 8,1);
+        E =
+        game.addThing(Tank.create('green', 2), 0,7);
+        game.addThing(Tank.create('green', 2), 1,0);
+        game.addThing(Tank.create('green', 2), 8,1);
         
-        I = game.addThing(Item.create('nitro'), 8,8);
+        I =
+        game.addThing(Item.create('nitro'), 8,8);
     },
     
     addWall : function addWall(x,y, w,h, isBoundary){
index 3c7837f..ce18020 100644 (file)
@@ -15,10 +15,6 @@ Tank.subclass('PlayerTank', {
     
     blocking : map.BLOCKING,
     
-    bodyColor   : '#E73075',
-    turretColor : '#A72F5B',
-    barrelColor : '#2E62C9',
-    
     // Attributes
     stats: {
         hp        : 1,          // health
index 1762a12..2c44d92 100644 (file)
@@ -28,9 +28,11 @@ Thing.subclass('Tank', function(Tank){
     // TODO: lookup projectile on Bullet
     
     Y.core.descriptors(this, {
-        bodyColor   : '#83BB32',
-        turretColor : '#1C625B',
-        barrelColor : '#D43B24',
+        colors : {
+            body   : '#83BB32',
+            turret : '#1C625B',
+            barrel : '#D43B24'
+        },
         
         // Bounding box
         blocking : map.BLOCKING,
@@ -73,6 +75,7 @@ Thing.subclass('Tank', function(Tank){
     this['init'] =
     function initTank(align){
         Thing.init.call(this, align);
+        this.colors = Y.extend({}, this.colors);
         this.atkGauge = new CooldownGauge(this.cooldowns.attack, this.width+1,this.height+1);
         this.onBulletDeath = this.onBulletDeath.bind(this);
     };
@@ -382,7 +385,8 @@ Thing.subclass('Tank', function(Tank){
     function render(parent){
         if (this.shape) this.shape.remove();
         
-        var w = this.width,  w2 = w/2
+        var colors = this.colors
+        ,   w = this.width,  w2 = w/2
         ,   h = this.height, h2 = h/2
         
         ,   r  = w / 4
@@ -394,7 +398,7 @@ Thing.subclass('Tank', function(Tank){
             new Rect(w,h)
                 .origin(this.originX,this.originY)
                 .position(this.loc.x, this.loc.y)
-                .fill(this.bodyColor)
+                .fill(colors.body)
                 .appendTo( parent ) ;
         
         if (this.showAttackCooldown)
@@ -403,29 +407,28 @@ Thing.subclass('Tank', function(Tank){
         this.turret =
             new Circle(r)
                 .position(w2, h2)
-                .fill(this.turretColor)
+                .fill(colors.turret)
                 .appendTo( this.shape ) ;
         
         this.barrel =
             new Rect(bw,bh)
                 .position(w2-2, h2-bh/2)
                 .origin(2, bh/2)
-                .fill(this.barrelColor)
+                .fill(colors.barrel)
                 .appendTo( this.shape ) ;
         
         return this;
     };
     
-    this['colors'] =
-    function colors(bodyColor, turretColor, barrelColor){
-        var names = Y('bodyColor', 'turretColor', 'barrelColor');
-        
+    this['tankColors'] =
+    function tankColors(bodyColor, turretColor, barrelColor){
+        var colors = this.colors;
         if (arguments.length === 0)
-            return names.generate( Y.op.curried.get(this) );
+            return colors;
         
-        if (bodyColor)   this.bodyColor   = bodyColor;
-        if (turretColor) this.turretColor = turretColor;
-        if (barrelColor) this.barrelColor = barrelColor;
+        if (bodyColor)   colors.body   = bodyColor;
+        if (turretColor) colors.turret = turretColor;
+        if (barrelColor) colors.barrel = barrelColor;
         return this;
     };