Adds docs, custom AI panel.
authordsc <david.schoonover@gmail.com>
Mon, 22 Nov 2010 19:24:11 +0000 (11:24 -0800)
committerdsc <david.schoonover@gmail.com>
Mon, 22 Nov 2010 19:24:11 +0000 (11:24 -0800)
12 files changed:
.gitignore [new file with mode: 0644]
bin/deploy.sh
css/lttl.css
doc/ai-challenge.md [moved from ai-challenge.md with 100% similarity]
doc/ai.md [moved from ai.md with 86% similarity]
doc/gameplay.md [new file with mode: 0644]
doc/notes.md [moved from notes.md with 100% similarity]
index.php
src/tanks/main.js
src/tanks/thing/custom-tank.js [new file with mode: 0644]
src/tanks/thing/player.js
tanks.php

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..c5083f9
--- /dev/null
@@ -0,0 +1 @@
+*.md.html
index 5251783..7f627eb 100755 (executable)
@@ -16,6 +16,10 @@ for opt in $*; do
     echo $opt | egrep -xq -e '--?h(e(lp?)?)?' && { halp; exit 0; }
 done
 
+for md in doc/*.md; do
+    markdown $md -f $md.html
+done
+
 EXCLUDE="--exclude=$(join ' --exclude=' 'tmp' $*)"
 echo "rsync -Cavz --delete $EXCLUDE ./* less.ly:lessly/hacking/tanks/"
 rsync -Cavz --delete $EXCLUDE ./* less.ly:lessly/hacking/tanks/
index b293744..051d12c 100644 (file)
@@ -36,11 +36,17 @@ table.grid td { /* outline:1px solid rgba(255,255,255,0.1); */
 
 .countdown { position:fixed; overflow:hidden; z-index:1000; text-align:center; border:10px solid #fff; color:#fff; }
 
+#ai { position:absolute; z-index:1002; width:80%; left:10%; }
+    #ai h2 { font-size:1.3em; }
+    #ai .box { width:100%; }
+    #ai .ready { width:5%; float:left; margin-right:1em; }
+    #ai textarea { width:90%; height:100px; }
+
 #viewport { position:relative; width:500px; height:500px; margin:1em auto; cursor:crosshair; }
 
 #overlay { position:fixed; top:0; left:0; width:100%; height:100%; background-color:#000; opacity:0.5; z-index:100; }
 
-#welcome { cursor:pointer; }
+#welcome .box { cursor:pointer; }
 #notes { /* position:fixed; top:4em; right:1em; color:#BFBFBF;*/ }
     #notes ul, #notes ol, #notes li { list-style:circle ! important; }
     #notes li { margin-left:1em; }
similarity index 100%
rename from ai-challenge.md
rename to doc/ai-challenge.md
diff --git a/ai.md b/doc/ai.md
similarity index 86%
rename from ai.md
rename to doc/ai.md
index 0dab8e6..5f4d6fb 100644 (file)
--- a/ai.md
+++ b/doc/ai.md
 - `shoot(x,y)`: Fires a shot at (x,y) if possible.
 - `move(x,y)`: Moves directly toward (x,y) if possible.
 - `ableToShoot()` -> `Boolean`: Whether your tank is able to fire at the moment.
-- `find(x1,y1,x2,y2)` -> `Agent[]`
+- `find(x1,y1,x2,y2)` -> `Agent[]`: Returns a list of all agents within the map bounds specified.
 - `findNearLike(ticks, filter)` -> `Agent[]`: Returns a list of agents within `ticks` movement distance away that match the filter.
 - `findClosest(agents)` -> `Agent`: Returns the closest agent to this tank in the supplied list, or null if none are supplied.
+- `willCollide(agents, wiggle)` -> `Agent[]`: Returns the list of agents which will collide with this agent (within `wiggle` width/height pixels).
 - `calculatePath(point)`
 - `calculatePath(x,y)`: Calculates a path from your current location to (x,y), taking into account walls, and then queues it for future moves.
 
diff --git a/doc/gameplay.md b/doc/gameplay.md
new file mode 100644 (file)
index 0000000..02a1ac4
--- /dev/null
@@ -0,0 +1,63 @@
+# The Littlest Battletank
+
+Inspired by Tanks minigame off Wii Play.
+
+## The Basics
+- Your tank has 1hp.
+- Your basic cannon shoots bullets. A bullet lives for one bounce or until it kills something. You can have up to 5 bullets at a time in the air.
+- When you die, you respawn after a few seconds. (In single player, it restarts the level.)
+
+## Controls
+- wasd, arrows: move your tank.
+- mouse: aim your reticule.
+- click, space, enter: fire a shot.
+- 0-9: use items.
+- All controls can be configured.
+
+## Ideas
+- Simplicity is king.
+- Only bosses have more than 1hp
+- Always on one screen
+- No stats: all items are qualitative
+- AI makes commentary on situations. "That was close. Sucker." "loool, you always die here."
+- Use TruRank-style player rating system, but the point of multiplayer will not be the ladder
+- Optional registration (Flash cookie every user)
+- Badges, awards, stats
+- Virtual currency from various in-game activities
+
+## Power-Ups
+- Missiles (fast, no bounce)
+- Refractor Rounds (slow, infi bounces)
+- Flamethrower (Cone AOE)
+- Shrapnel Rounds (splits once on impact)
+- Mortar Rounds (Projectile AOE)
+- Mines (Stationary Prox AOE)
+- Heatseekers (Projectile Prox)
+- Nukes (Absurd AOE which often kills you)
+- Portal Cannon (Exchanges your position with your cursor)
+- K-Boss Shield (Absorbs 1 damage)
+- Gin & Tonic / iPhone 3G / Hannah Montana Lamp (Extra Life)
+- Deuschund Trebuchet (Parabolic Arc lulz)
+- Light Cannon (Faster Move, -1 Shots in Air)
+- EMP Device (aka, the "Stunna") (Freezes everyone in place. Including you.)
+
+## Mechanics
+- AOE
+- Shot Travel Speed
+- Shot Bounces
+- Shot Cooldown
+- Shots in Air
+- Move Speed
+- HP (Bosses only)
+- Allies -- companion AI tanks which play for your side, but they can still damage you
+- Can use Items
+- AI type, quality
+- Mutable Environment?
+
+
+
+
+
+
+
+
similarity index 100%
rename from notes.md
rename to doc/notes.md
index 0f8add7..7376a28 100644 (file)
--- a/index.php
+++ b/index.php
@@ -7,8 +7,17 @@
 </head>
 <body class="lttl tanks">
 
+
 <div id="overlay"></div>
 
+<div id="ai" style="display:none" class="bigblue">
+    <div class="box">
+        <h2>Add Tank AI</h2>
+        <textarea id="custom-tank"></textarea>
+        <div class="ready pinkbutton rounded">Ready</div>
+    </div>
+</div>
+
 <div id="welcome" class="bigblue">
     <div class="box">
         <h1>The Littlest Battletank</h1>
@@ -26,7 +35,6 @@
     </div>
 </div>
 
-
 <div id="viewport"></div>
 
 <div id="debug" style="display:none"><div class="inner box">
index 250f47c..6944542 100644 (file)
@@ -9,8 +9,24 @@ function main(){
     qkv = Y(window.location.search.slice(1)).fromKV().end();
     
     /// Debug ///
+    if (qkv.ai) {
+        $('#welcome').hide();
+        $('#ai').toggle();
+        $('#ai textarea')[0].focus();
+    }
     if (qkv.debug) $('#debug').toggle();
     
+    $('#ai .ready').bind('click', function(evt){
+        try {
+            var script = $('#custom-tank').val();
+            Tank.prototype.act = eval('(function(){ with(this){'+script+'} })');
+            $('#ai').hide();
+            startGame();
+        } catch(e) {
+            alert('AI Error! '+e);
+        }
+    });
+    
     // Show debug
     $(document).bind('keydown', 'ctrl+c', function(evt){ $('#debug').toggle(); });
     
@@ -73,13 +89,13 @@ function teardownGame(){
 function setupUI(){
     if ( gameExists() ) teardownUI();
     
-    $('#welcome').show();
+    if (!qkv.ai) $('#welcome').show();
     LBT.loop.spark = new FpsSparkline(LBT.loop, '.fps-sparkline', 0,0);
     initConfig();
     LBT.root.draw();
     
     // Start button (click or return key)
-    $(document).bind('click', startGame);
+    if (!qkv.ai) $(document).bind('click', startGame);
     $(document).bind('keydown', 'return', startGame);
     
     
diff --git a/src/tanks/thing/custom-tank.js b/src/tanks/thing/custom-tank.js
new file mode 100644 (file)
index 0000000..c9a7267
--- /dev/null
@@ -0,0 +1,8 @@
+CustomTank = Tank.subclass('CustomTank', {
+    
+    init : function initCustomTank(align, script){
+        Tank.init.call(this, align);
+        this.act = eval('(function(){ with(this){'+script+'} })');
+    }
+    
+});
\ No newline at end of file
index efad127..efb9caf 100644 (file)
@@ -25,15 +25,18 @@ PlayerTank = Tank.subclass('PlayerTank', {
         this.activeKeys = new Y.YArray();
         this.queue = [];
         
-        // tank.act = this.act; // Override tank actions with player control
-        // tank.move = this.move;
-        
-        $(window)
-            .bind('keydown',   this.keydown.bind(this))
-            .bind('keyup',     this.keyup.bind(this))
-            .bind('mousedown', this.mousedown.bind(this))
-            .bind('mouseup',   this.mouseup.bind(this))
-            .bind('mousemove', this.mousemove.bind(this))
+        this.keydown   = this.keydown.bind(this);
+        this.keyup     = this.keyup.bind(this);
+        this.mousedown = this.mousedown.bind(this);
+        this.mouseup   = this.mouseup.bind(this);
+        this.mousemove = this.mousemove.bind(this);
+        
+        $(document)
+            .bind('keydown',   this.keydown)
+            .bind('keyup',     this.keyup)
+            .bind('mousedown', this.mousedown)
+            .bind('mouseup',   this.mouseup)
+            .bind('mousemove', this.mousemove)
             ;
     },
     
index 8230724..6177a46 100644 (file)
--- a/tanks.php
+++ b/tanks.php
@@ -24,6 +24,7 @@ class Tanks {
         "src/tanks/thing/thing.js",
         "src/tanks/thing/bullet.js",
         "src/tanks/thing/tank.js",
+        "src/tanks/thing/custom-tank.js",
         "src/tanks/thing/player.js",
         
         "src/tanks/map/loc.js",