Adds random bullet spawns, makes them collide.
authordsc <david.schoonover@gmail.com>
Wed, 10 Nov 2010 16:25:57 +0000 (08:25 -0800)
committerdsc <david.schoonover@gmail.com>
Wed, 10 Nov 2010 16:25:57 +0000 (08:25 -0800)
index.php
src/tanks/main-ui.js
src/tanks/thing/bullet.js
src/tanks/thing/tank.js

index 92af813..af12c2d 100644 (file)
--- a/index.php
+++ b/index.php
@@ -13,7 +13,7 @@
 <h1>The Littlest Battletank</h1>
 
 <div id="controls">
-    <label for="nbullets">Num Bullets</label> <input id="nbullets" name="nbullets" value="5" type="text">
+    <label for="nbullets">Num Bullets</label> <input id="nbullets" name="nbullets" value="15" type="text">
 </div>
 
 <ul id="info" class="rounded">
index bbf85d5..a929878 100644 (file)
@@ -17,7 +17,7 @@ function setupUI(){
         if ( isNaN(n) || n === bullets.size() ) return;
         
         while (n < bullets.size()) {
-            var i = rand(0, bullets.size()-1);
+            var i = Math.round(rand(0, bullets.size()-1));
             bullets.remove( bullets.attr(i).remove() );
         }
         
@@ -31,8 +31,9 @@ function setupUI(){
     LBT.root.draw();
     
     setInterval(updateInfo, 1000);
-    updateInfo();
+    // updateInfo();
     
+    toggleGame();
     // Fix grid-size on resize
     // $(window).bind('resize', resizeGame);
 }
index 1e80020..9db727e 100644 (file)
@@ -27,6 +27,13 @@ Bullet = new Y.Class('Bullet', Thing, {
             Thing.fillStats(this.stats) );
     },
     
+    remove : function remove(){
+        if (this.shape) this.shape.remove();
+        if (this.tline) this.tline.remove();
+        if (this.game)  this.game.killUnit(this);
+        return this;
+    },
+    
     createCooldowns : Y.op.nop,
     
     // setLocation : function setLocation(x,y){
index 6d22245..cc34319 100644 (file)
@@ -1,7 +1,7 @@
 
 Tank = new Y.Class('Tank', Thing, {
     projectile : Bullet,
-    blocking: true,
+    blocking: false,
     
     // Bounding box size
     width  : REF_SIZE*0.7,