Checkpoint in module refactor for the new server git repo.
authordsc <david.schoonover@gmail.com>
Wed, 1 Dec 2010 09:45:21 +0000 (01:45 -0800)
committerdsc <david.schoonover@gmail.com>
Wed, 1 Dec 2010 09:45:21 +0000 (01:45 -0800)
46 files changed:
bin/cjs.py
doc/gameplay.md
index.php
lib/cjs/require.js
lib/jquery.hotkeys.js
lib/jquery.hotkeys.min.js
lib/jquery.sparkline.js
lib/jquery.sparkline.min.js
src/Y/class.cjs
src/Y/core.cjs
src/Y/index.cjs
src/Y/modules/y.event.cjs
src/Y/type.cjs
src/Y/types/function.cjs
src/evt/class.cjs [moved from src/evt/evt.class.js with 100% similarity]
src/ezl/loop/eventloop.cjs
src/ezl/math/rect.cjs
src/ezl/math/vec.cjs
src/ezl/shape/circle.cjs
src/ezl/shape/line.cjs
src/ezl/shape/rect.cjs
src/ezl/shape/shape.cjs
src/ezl/util/tree/quadtree.cjs
src/tanks/config.cjs
src/tanks/game.cjs
src/tanks/globals.js [moved from src/tanks/globals.cjs with 68% similarity]
src/tanks/index.cjs
src/tanks/map/index.cjs
src/tanks/map/level.cjs
src/tanks/map/pathmap.cjs
src/tanks/map/trajectory.cjs
src/tanks/map/wall.cjs [new file with mode: 0644]
src/tanks/thing/bullet.cjs
src/tanks/thing/customtank.cjs [moved from src/tanks/thing/custom-tank.cjs with 58% similarity]
src/tanks/thing/index.cjs
src/tanks/thing/player.cjs
src/tanks/thing/tank.cjs
src/tanks/thing/thing.cjs
src/tanks/ui/config.cjs [moved from src/tanks/ui/ui-config.cjs with 90% similarity]
src/tanks/ui/grid.cjs
src/tanks/ui/index.cjs
src/tanks/ui/main.cjs
src/tanks/ui/ui.cjs [deleted file]
src/tanks/util/config.cjs
tags.php [new file with mode: 0644]
tanks.php

index dbdbc72..1bd5429 100755 (executable)
@@ -7,11 +7,12 @@ __version__   = (0, 0, 1)
 __all__ = ('ResolutionError', 'Module', 'JSResolver',)
 
 
-import sys, re, json
+import sys, re, jsond as json
 from itertools import chain, repeat
 from collections import defaultdict
 from subprocess import Popen, check_output, STDOUT, PIPE
 from glob import glob
+from pprint import pprint, pformat
 
 from bunch import *
 from path import path
@@ -72,6 +73,8 @@ def partition(it, sep):
         return (before, None, [])
     return (before, sep, list(it))
 
+
+
 def canonicalise(query, base=None):
     """ query: A module ID (relative or absolute) or filepath
         base: Optional. The referring module ID.
@@ -185,6 +188,9 @@ class Module(Bunch):
     def requires(self):
         return self.calcRequires('_at_requires') + self._requires
     
+    def __json_default__(self):
+        return dict( (k,self[k]) for k in 'id file name _requires _at_requires'.split(' ') )
+    
     def __hash__(self):
         return hash(self.id)
     
@@ -206,32 +212,12 @@ class Module(Bunch):
 class CommonJS(object):
     """ Compiles JS modules into browser-safe JS files. """
     
-    @staticmethod
-    def discover(files, repos, **options):
-        "Discover listed modules and their dependencies."
-        cjs   = CommonJS(repos, **options)
-        queue = [ cjs.lookup(f) for f in files ]
-        seen  = set()
-        while queue:
-            mod = queue.pop(0)
-            seen.add(mod)
-            # print mod, "requirements:", mod.requires
-            for query in mod.requires:
-                # print mod, "requires", query
-                req = cjs.lookup(query, mod)
-                if req not in seen:
-                    queue.append(req)
-        if cjs.deps_name:
-            cjs.genDepLoader()
-        return cjs
-    
-    
     repos   = []
     modules = {} # id -> Module
     _graph    = None # id -> set(dependants)
     _at_graph = None # id -> set(dependants)
     
-    def __init__(self, repos, out='build', deps_name=None, clean=True, **options):
+    def __init__(self, repos, out='build', save='build', deps_name=None, clean=True, **options):
         self.modules  = {}
         self.options  = options
         self.deps_name = deps_name
@@ -274,6 +260,11 @@ class CommonJS(object):
         for k, mod in self.modules.iteritems():
             yield k, mod
     
+    def reset(self):
+        self._graph = None
+        self._at_graph = None
+        return self
+    
     def calcGraph(self, attr):
         if self._graph is None:
             graph   = self._graph    = defaultdict(set)
@@ -294,31 +285,38 @@ class CommonJS(object):
         return self.calcGraph('_at_graph')
     
     def tsort(self, graph):
-        p = Popen(['tsort'], stderr=STDOUT, stdin=PIPE, stdout=PIPE)
+        p = Popen(['tsort'], stderr=sys.stderr, stdin=PIPE, stdout=PIPE)
         deps = '\n'.join( '%s %s' % (id, dep.id) for (id, deps) in graph.iteritems() for dep in deps )
         p.stdin.write(deps)
         p.stdin.close()
         if p.wait() != 0:
             raise ResolutionError('Cannot resolve dependencies! Requirements must be acyclic!')
-        return p.stdout.read()
+        return p.stdout.read().strip().split('\n')
     
     @property
     def dependencies(self):
-        deps = (self.tsort(self.atGraph)+self.tsort(self.graph)).strip().split('\n')
-        for i, dep in reversed(list(enumerate(deps[:]))):
-            try:
-                idx = deps.index(dep, 0, i-1)
-                if i != idx:
-                    del deps[idx]
-            except ValueError: pass
-        return deps
+        atg = self.tsort(self.atGraph)
+        nog = self.tsort(self.graph)
+        atdeps = self.atGraph.keys()
+        
+        for dep in atg[:]:
+            if dep not in atdeps:
+                try: atg.remove(dep)
+                except ValueError: pass
+            else:
+                try: nog.remove(dep)
+                except ValueError: pass
+        
+        # print '\nAtKeys:\n', pformat(atdeps), '\n'
+        # print '\nAtDeps:\n', pformat(atg), '\n'
+        # print '\nNoKeys:\n', pformat(nog), '\n'
+        return atg+nog
     
     def dumpDependencies(self):
         column = Popen(['column', '-s', '\t', '-t'], stderr=sys.stderr, stdin=PIPE, stdout=PIPE)
-        mods = self.modules.values()
-        for mod in sorted(mods, key=lambda m: len(m.requires), reverse=True):
+        # for mod in sorted(self.modules.values(), key=lambda m: len(m.requires), reverse=True):
+        for mod in sorted(self.modules.values()):
             column.stdin.write('%s\t->\t%r\n' % (mod, sorted(mod.requires)))
-            # print '%s\t->\t%r' % (mod, sorted(mod.requires))
         column.stdin.close()
         if column.wait() != 0:
             print >> sys.stderr, 'Some sort of error has occurred!'
@@ -335,6 +333,54 @@ class CommonJS(object):
     @property
     def scriptTags(self):
         return '\n'.join( '<script src="{}" type="text/javascript"></script>'.format(uri) for uri in self.uris )
+    
+    def save(self, dir):
+        with (path(dir)/'.modules.json').open('w') as f:
+            json.dump({
+                'modules' : self.modules,
+                'ensure' : dict( (id, list(mod.id for mod in mods)) for id,mods in self.atGraph.iteritems() ),
+                'graph'  : dict( (id, list(mod.id for mod in mods)) for id,mods in self.graph.iteritems() ),
+            }, f, indent=4)
+        return self
+    
+    @staticmethod
+    def discover(files, repos, **options):
+        "Discover listed modules and their dependencies."
+        cjs = CommonJS(repos, **options)
+        
+        # print >> sys.stderr, '\n[ %s ]' % f
+        
+        queue = [ cjs.reset().lookup(f) for f in files ]
+        seen  = set()
+        while queue:
+            mod = queue.pop(0)
+            seen.add(mod)
+            # print mod, "requirements:", mod.requires
+            for query in mod.requires:
+                # print mod, "requires", query
+                req = cjs.lookup(query, mod)
+                if req not in seen:
+                    queue.append(req)
+        
+        if options.get('deps_name', None):
+            cjs.genDepLoader()
+        
+        if options.get('print_deps', None):
+            print >> sys.stderr, '\n[ %s ]' % f
+            print >> sys.stderr, 'All Dependencies:'
+            print >> sys.stderr, cjs.dumpDependencies()
+            print >> sys.stderr, ''
+            print >> sys.stderr, 'Resolution:'
+            print >> sys.stderr, '\n'.join(cjs.dependencies)
+        
+        if options.get('script_tags', None):
+            print cjs.scriptTags
+        
+        if options.get('state', None):
+            cjs.save(options['state'])
+        
+        return cjs
+
 
 
 
@@ -360,6 +406,9 @@ def main():
         help="Generates a JS script with the given name which doc-writes tags for this set of modules.")
     parser.add_option("-s", "--script-tags", default=False, action="store_true",
         help="Emits script-tags for this set of modules in dependency order. [default: %default]")
+    parser.add_option("-S", "--state", default='build',
+        help="Directory to save build state. [default: %default]")
+    
     
     (options, args) = parser.parse_args()
     
@@ -373,21 +422,11 @@ def main():
     
     # print 'files:', files, 'repos:', (repos or ['.'])
     try:
-        js = CommonJS.discover(files=files, repos=repos or ['.'], **options.__dict__)
+        cjs = CommonJS.discover(files=files, repos=repos or ['.'], **options.__dict__)
     except ResolutionError as ex:
         print >> sys.stderr, str(ex)
         return 1
     
-    if options.script_tags:
-        print js.scriptTags
-    
-    if options.print_deps:
-        print >> sys.stderr, 'All Dependencies:'
-        print >> sys.stderr, js.dumpDependencies()
-        print >> sys.stderr, ''
-        print >> sys.stderr, 'Resolution:'
-        print >> sys.stderr, '\n'.join(js.dependencies)
-    
     return 0
 
 if __name__ == '__main__':
index 02a1ac4..fd3a511 100644 (file)
@@ -1,63 +1,93 @@
 # The Littlest Battletank
 
-Inspired by Tanks minigame off Wii Play.
+Inspired by the Tanks minigame in 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?
+
+### Desktop Controls
+
+- Move: wasd, arrows for cardinal directions; combine for 45-degree moves
+- Shoot:
+    - Aim your reticule with the mouse
+    - Click, or press space to fire a shot
+- Items: Press `12345zxc
+- Zoom: Mouse wheel
+- Customization:
+    - Keyboard controls can be rebound
+    - Multiple UI trays
+
+### iOS Controls
+- Move: Trace a path from your tank with your finger
+- Shoot:
+     - Tap once somewhere sufficiently far from your tank to shoot one bullet on a trajectory aimed at that point
+     - Tap once and hold to see the trajectory line
+          - Move your finger to drag the line at a new point
+          - Release the tap to shoot along that trajectory
+          - Tap with your other hand sufficiently far from your tank and the current trajectory point to cancel
+- Items: On-screen buttons, possibly modal
+- Zoom: Pinch
+- Customization:
+     - Modal buttons used to switch between multiple UI "trays" with buttons
+     - Free gestures can be rebound (two/three finger swipe, double-tap, triple-tap)
+
+
+## Gameplay Ideas
+- No camera control: camera centers on tank and moves with it, though player can zoom the map
+- No number games: all items are qualitative (so, ex: only bosses have more than 1hp, but items (like shields) might absorb damage)
+- Allies: companion AI tanks which play for your side (beware friendly fire)- Mutable Environment: obstacles can be destroyed with the right weapons, enemies can be pushed
 
 
+## Items
 
+### Cannons
+- Missiles: Faster projectile, but no bounce
+- Refractor Rounds: Slower projectile, but infi bounces
+- Shrapnel Rounds: Projectile that splits instead of bounce
 
+### Heavy Munitions
+- Flamethrower: Cone AOE
+- Mortar Rounds: Projectile with AOE on detonation
+- Proximity Missiles: Projectile that explodes on prox
+- Mines: Stationary prox AOE
 
+### Special Weapons
+- Heatseekers: Projectile that will guide around walls to get to your target point, and then explodes even if no one is there
+- Nuke: Slow projectile with enormous AOE (reminder: friendly fire)
+- Trebuchet Rounds: Projectile which only collides when it reaches its destination (as if it was fired in a parabolic arc)
+- Portal Cannon: Makes source/dest wormholes
 
+### Passives
+- Light Ordinance: Faster move, fewer shots in air
+- Tactical Driver: Attempts to automatically move your tank out of harm's way when a bullet is imminent
+- Chameleon Engine: Makes enemies unable to see you for a limited time, confusing pathing
+
+### Shields
+- Turret Shield: extends 45-degrees around tour tank, centered on the barrel; impact pushes your tank back
+- Orbital Shield: small pellet-shield that orbits your tank
+- Stationary Shield: stationary shield sphere, passable to tanks but not bullets
+- Imprinted Stationary Shield: as the stationary shield, but passable only to your team and not others
+
+### Consumables
+- Cloudpot: Your tank deploys an emergency zeppelin to float quickly from your current position to your cursor. Tank can only be hit by Trebuchet Rounds during that time.
+- The Stunna Shocka (EMP Device): Freezes all tanks in place (including you)
+
+
+## Tank Attributes
+- Movement: speed, turning speed
+- Cannon: cooldown, max in air, recoil?
+- Bullets: speed, num bounces, proximity, AOE explosion
+- Toughness: hp (Bosses only), shields, resistance to certain classes of weapons
+
+
+## Flavor
+- AI makes commentary on situations. "That was close. Sucker." "loool, you always die here."
+- Papercraft art style, vector graphics
 
 
index 3ac3f78..8d435d9 100644 (file)
--- a/index.php
+++ b/index.php
@@ -29,7 +29,7 @@
 <div id="ai" style="display:none" class="bigblue">
     <div class="box">
         <h2>Add Tank AI</h2>
-        <textarea id="custom-tank"></textarea>
+        <textarea id="customtank"></textarea>
         <div class="ready pinkbutton rounded">Ready</div>
     </div>
 </div>
index 98d77d7..586ad3e 100644 (file)
@@ -10,7 +10,7 @@ function require(id){
     if ( !modules.hasOwnProperty(id) )
         throw new Error('No such module "'+id+'"!');
     
-    var module  = modules[ids]
+    var module  = modules[id]
     ,   exports = module.exports = {};
     
     // TODO: load the module
index fbd71c7..315014f 100644 (file)
@@ -1,3 +1,4 @@
+//@require('jquery')
 /*
  * jQuery Hotkeys Plugin
  * Copyright 2010, John Resig
index 6689e7a..90a601f 100644 (file)
@@ -1 +1,2 @@
+//@require('jquery')
 (function(b){b.fn.__bind__=b.fn.bind;b.fn.__unbind__=b.fn.unbind;b.fn.__find__=b.fn.find;var a={version:"0.7.9",override:/keypress|keydown|keyup/g,triggersMap:{},specialKeys:{27:"esc",9:"tab",32:"space",13:"return",8:"backspace",145:"scroll",20:"capslock",144:"numlock",19:"pause",45:"insert",36:"home",46:"del",35:"end",33:"pageup",34:"pagedown",37:"left",38:"up",39:"right",40:"down",109:"-",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12",191:"/"},shiftNums:{"`":"~","1":"!","2":"@","3":"#","4":"$","5":"%","6":"^","7":"&","8":"*","9":"(","0":")","-":"_","=":"+",";":":","'":'"',",":"<",".":">","/":"?","\\":"|"},newTrigger:function(e,d,f){var c={};c[e]={};c[e][d]={cb:f,disableInInput:false};return c}};a.specialKeys=b.extend(a.specialKeys,{96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9",106:"*",107:"+",109:"-",110:".",111:"/"});b.fn.find=function(c){this.query=c;return b.fn.__find__.apply(this,arguments)};b.fn.unbind=function(h,e,g){if(b.isFunction(e)){g=e;e=null}if(e&&typeof e==="string"){var f=((this.prevObject&&this.prevObject.query)||(this[0].id&&this[0].id)||this[0]).toString();var d=h.split(" ");for(var c=0;c<d.length;c++){delete a.triggersMap[f][d[c]][e]}}return this.__unbind__(h,g)};b.fn.bind=function(j,f,k){var h=j.match(a.override);if(b.isFunction(f)||!h){return this.__bind__(j,f,k)}else{var n=null,i=b.trim(j.replace(a.override,""));if(i){n=this.__bind__(i,f,k)}if(typeof f==="string"){f={combi:f}}if(f.combi){for(var m=0;m<h.length;m++){var d=h[m];var g=f.combi.toLowerCase(),e=a.newTrigger(d,g,k),l=((this.prevObject&&this.prevObject.query)||(this[0].id&&this[0].id)||this[0]).toString();e[d][g].disableInInput=f.disableInInput;if(!a.triggersMap[l]){a.triggersMap[l]=e}else{if(!a.triggersMap[l][d]){a.triggersMap[l][d]=e[d]}}var c=a.triggersMap[l][d][g];if(!c){a.triggersMap[l][d][g]=[e[d][g]]}else{if(c.constructor!==Array){a.triggersMap[l][d][g]=[c]}else{a.triggersMap[l][d][g][c.length]=e[d][g]}}this.each(function(){var o=b(this);if(o.attr("hkId")&&o.attr("hkId")!==l){l=o.attr("hkId")+";"+l}o.attr("hkId",l)});n=this.__bind__(h.join(" "),f,a.handler)}}return n}};a.findElement=function(c){if(!b(c).attr("hkId")){if(b.browser.opera||b.browser.safari){while(!b(c).attr("hkId")&&c.parentNode){c=c.parentNode}}}return c};a.handler=function(e){var o=a.findElement(e.currentTarget),i=b(o),d=i.attr("hkId");if(d){d=d.split(";");var g=e.which,q=e.type,p=a.specialKeys[g],n=!p&&String.fromCharCode(g).toLowerCase(),h=e.shiftKey,c=e.ctrlKey,m=e.altKey||e.originalEvent.altKey,f=null;for(var r=0;r<d.length;r++){if(a.triggersMap[d[r]][q]){f=a.triggersMap[d[r]][q];break}}if(f){var j;if(!h&&!c&&!m){j=f[p]||(n&&f[n])}else{var l="";if(m){l+="alt+"}if(c){l+="ctrl+"}if(h){l+="shift+"}j=f[l+p];if(!j){if(n){j=f[l+n]||f[l+a.shiftNums[n]]||(l==="shift+"&&f[a.shiftNums[n]])}}}if(j){var s=false;for(var r=0;r<j.length;r++){if(j[r].disableInInput){var k=b(e.target);if(i.is("input")||i.is("textarea")||i.is("select")||k.is("input")||k.is("textarea")||k.is("select")){return true}}s=s||j[r].cb.apply(this,[e])}return s}}}};window.hotkeys=a;return b})(jQuery);
\ No newline at end of file
index 1c35b5f..06a630e 100644 (file)
@@ -1,3 +1,4 @@
+//@require('jquery')
 /**
 *
 * jquery.sparkline.js
index 08a30bf..2868b2b 100644 (file)
@@ -1,5 +1,5 @@
+//@require('jquery')
 /* jquery.sparkline 1.5.1 - http://omnipotent.net/jquery.sparkline/ */
-
 (function($){$.fn.simpledraw=function(width,height,use_existing){if(use_existing&&this[0].vcanvas)return this[0].vcanvas;if(width==undefined)width=$(this).innerWidth();if(height==undefined)height=$(this).innerHeight();if($.browser.hasCanvas){return new vcanvas_canvas(width,height,this);}else if($.browser.msie){return new vcanvas_vml(width,height,this);}else{return false;}};var pending=[];$.fn.sparkline=function(uservalues,options){var options=$.extend({type:'line',lineColor:'#00f',fillColor:'#cdf',defaultPixelsPerValue:3,width:'auto',height:'auto',composite:false},options?options:{});return this.each(function(){var render=function(){var values=(uservalues=='html'||uservalues==undefined)?$(this).text().split(','):uservalues;var width=options.width=='auto'?values.length*options.defaultPixelsPerValue:options.width;if(options.height=='auto'){if(!options.composite||!this.vcanvas){var tmp=document.createElement('span');tmp.innerHTML='a';$(this).html(tmp);height=$(tmp).innerHeight();$(tmp).remove();}}else{height=options.height;}
 $.fn.sparkline[options.type].call(this,values,options,width,height);}
 if(($(this).html()&&$(this).is(':hidden'))||($.fn.jquery<"1.3.0"&&$(this).parents().is(':hidden'))){pending.push([this,render]);}else{render.call(this);}});};$.sparkline_display_visible=function(){for(var i=pending.length-1;i>=0;i--){var el=pending[i][0];if($(el).is(':visible')&&!$(el).parents().is(':hidden')){pending[i][1].call(el);pending.splice(i,1);}}};$.fn.sparkline.line=function(values,options,width,height){var options=$.extend({spotColor:'#f80',spotRadius:1.5,minSpotColor:'#f80',maxSpotColor:'#f80',lineWidth:1,normalRangeMin:undefined,normalRangeMax:undefined,normalRangeColor:'#ccc',chartRangeMin:undefined,chartRangeMax:undefined,chartRangeMinX:undefined,chartRangeMaxX:undefined},options?options:{});var xvalues=[],yvalues=[],yminmax=[];for(i=0;i<values.length;i++){var v=values[i];var isstr=typeof(values[i])=='string';var isarray=typeof(values[i])=='object'&&values[i]instanceof Array;var sp=isstr&&values[i].split(':');if(isstr&&sp.length==2){xvalues.push(Number(sp[0]));yvalues.push(Number(sp[1]));yminmax.push(Number(sp[1]));}else if(isarray){xvalues.push(values[i][0]);yvalues.push(values[i][1]);yminmax.push(values[i][1]);}else{xvalues.push(i);if(values[i]===null||values[i]=='null'){yvalues.push(null);}else{yvalues.push(Number(values[i]));yminmax.push(Number(values[i]));}}}
index dc1a4b5..5e90e10 100644 (file)
@@ -1,9 +1,21 @@
 // Inspired by John Resig's "Simple Class Inheritence" -- http://ejohn.org/blog/simple-javascript-inheritance/
 
-var type      = require('Y/type')
-,   YFunction = require('Y/types/function').YFunction
-,   core      = require('Y/core')
-,   slice     = core.slice
+var type       = require('Y/type')
+,   core       = require('Y/core')
+,   YFunction  = require('Y/types/function').YFunction
+,   isFunction = type.isFunction
+,   slice      = core.slice
+
+,   globals   = (function(){ return this; })()
+,   _Object   = globals.Object
+,   _Function = globals.Function
+,   _Array    = globals.Array
+,   _String   = globals.String
+,   _Number   = globals.Number
+
+,   slice    = _Array.prototype.slice
+,   hasOwn   = _Object.prototype.hasOwnProperty
+,   getProto = _Object.getPrototypeOf
 
 ,   KNOWN_CLASSES = type.type.KNOWN_CLASSES
 ,   classToString = function toString(){ return this.className+"()"; }
index 0725a30..ee42dc3 100644 (file)
@@ -5,6 +5,7 @@ var undefined
 ,   _Array    = globals.Array
 ,   PT = "prototype"
 ,   slice = _Array[PT].slice
+,   type = require('Y/type')
 ;
 
 // function slice(a){
@@ -47,7 +48,7 @@ function map(o, fn){
 }
 
 function forEach(o, fn){
-    map(o, fn, cxt);
+    map(o, fn, arguments[2] || o);
     return o;
 }
 
@@ -86,7 +87,7 @@ function dset(o, key, value, def){
 function attr(o, key, value, def){
     if ( !o || key === undefined ) return o;
     
-    if ( Y.isPlainObject(key) )
+    if ( type.isPlainObject(key) )
         return extend(o, key);
     
     if ( value !== undefined || def !== undefined ){
index cdfd44e..f15d71a 100644 (file)
@@ -43,11 +43,13 @@ addNames('curry methodize genericize compose chain memoize', yfn);
 // Curry all operators
 var op = require('Y/op');
 core.forEach(op, YFunction);
-Y['op'] = op['curried'] = op.extend({}, core.map(yfn.curry, op));
-// Y['op'] = core.reduce(op, function(Yop, fn, k){
-//     Yop[k] = yfn.curry(fn);
-//     return Yop;
-// }, {});
+// Y['op'] = op['curried'] = op.extend({}, core.map(op, yfn.curry));
+Y['op'] =
+op['curried'] = 
+    core.reduce(op, function(Yop, fn, k){
+        Yop[k] = fn.curry();
+        return Yop;
+    }, {});
 
 // var yclass = require('Y/types/class');
 addNames('Class subclass instantiate fabricate YBase',
index 577aa02..aa39688 100644 (file)
@@ -1,3 +1,4 @@
+var Y = require('Y').Y;
 Y['event'] = exports;
 
 /**
@@ -6,8 +7,9 @@ Y['event'] = exports;
  * TODO: If DOM event, wrap with consistent API.
  * TODO: use jQuery if present to wrap events.
  */
-var YEvent = exports['YEvent'] = 
-Y.YObject.subclass('YEvent', {
+var Event =
+exports['Event'] =
+Y.YObject.subclass('Event', {
     init : function init( type, target, trigger, data ){
         data = data || {};
         for (var k in data) this[k] = data[k];
@@ -18,7 +20,7 @@ Y.YObject.subclass('YEvent', {
         this.trigger = trigger || target;
     },
     
-    toString: function(){ return "YEvent("+this.type+")"; }
+    toString: function(){ return "Event("+this.type+")"; }
 })
 
 /**
@@ -42,7 +44,7 @@ Y.YObject.subclass('YEvent', {
     },
     
     fire : function fire(evtname, trigger, data, async){
-        var evt = new YEvent(evtname, this.target, trigger, data);
+        var evt = new Event(evtname, this.target, trigger, data);
         if (async)
             setTimeout(this.dispatchEvent.bind(this, evt), 10);
         else
@@ -68,7 +70,8 @@ Y.YObject.subclass('YEvent', {
     }
 },
 
-Emitter = exports['Emitter'] =
+Emitter =
+exports['Emitter'] =
 Y.YObject.subclass('Emitter', 
     Y.extend({
         'init' : function(target, parent){
index 0063683..83e40a4 100644 (file)
@@ -37,7 +37,7 @@ function type_of(obj){
 }
 
 isArray.types = [];
-function isArray(obj)    { return type_of(obj) === "array" || obj instanceof Y.YArray; }
+function isArray(obj)    { return type_of(obj) === "array" /*|| obj instanceof Y.YArray*/ ; }
 function isFunction(obj) { return type_of(obj) === "function"; }
 function isString(obj)   { return type_of(obj) === "string"; }
 function isNumber(obj)   { return type_of(obj) === "number"; }
@@ -93,7 +93,7 @@ function type( o ) {
 
 function is( A, B ){
     if ( isArray(B) )
-        return B.map( Y.is(A) ).any();
+        return B.map( is.bind(this,A) ).any();
     else {
         var AT = type(A), BT = type(B);
         return (A instanceof BT || B instanceof AT || AT === BT);
index 88e81ba..7d8f570 100644 (file)
@@ -1,6 +1,7 @@
 var undefined
 ,   WRAPS   = "__wraps__"
 ,   globals = (function(){ return this; })()
+,   _Function = globals.Function
 
 ,   core   = require('Y/core')
 ,   type   = require('Y/type')
@@ -8,7 +9,7 @@ var undefined
 ,   isFunction    = type.isFunction
 ,   slice         = core.slice
 
-,   _   = exports._ = YFunction._ = {}
+,   _   = YFunction._ = {}
 ,   YFP = YFunction.prototype
 ;
 
@@ -47,7 +48,7 @@ function curry(fn){
     if (fn.__curried__)
         return fn.apply(this, slice.call(arguments,1));
     
-    fn = Function.toFunction(fn);
+    fn = _Function.toFunction(fn);
     var args = slice.call(arguments, 1)
     ,   L = unwrap(fn).length;
     
@@ -103,14 +104,14 @@ function genericize( fn ) {
 
 function _composer(x,fn){ return fn.call(this, x); }
 function compose(f,g){
-    var fns = slice.call(arguments).map(Function.toFunction);
+    var fns = slice.call(arguments).map(_Function.toFunction);
     return function(){
         return fns.reduce(_composer, slice.call(arguments), this);
     };
 }
 
 function chain(f,g){
-    var fns = slice.call(arguments).map(Function.toFunction);
+    var fns = slice.call(arguments).map(_Function.toFunction);
     
     if ( g.__sequence__ )
         fns = g.__sequence__.concat( fns.slice(1) );
@@ -302,6 +303,4 @@ YFP.extend(core.map(exports, methodize));
 
 // Export these last to avoid methodizing them
 exports['YFunction']  = YFunction;
-
-// Attach our methods to our exports!
-core.forEach(exports, YFunction);
+exports._ = _;
similarity index 100%
rename from src/evt/evt.class.js
rename to src/evt/class.cjs
index 783a03c..949deee 100644 (file)
@@ -123,5 +123,3 @@ function decorate(delegate){
     return delegate;
 }
 
-
-})();
index 6f278e2..c5e8794 100644 (file)
@@ -1,4 +1,5 @@
-var Vec = require('ezl/math/vec').Vec
+var Y = require('Y').Y
+,   Vec = require('ezl/math/vec').Vec
 ,
 
 Rect =
index 68c9844..a3cb5ac 100644 (file)
@@ -1,7 +1,10 @@
+var Y = require('Y').Y
+,
+
 /**
  * A 2-dimensional vector.
  */
-var Vec =
+Vec =
 exports['Vec'] =
 new Y.Class('Vec', [], {
     
index 4f28285..8e61bf6 100644 (file)
@@ -1,9 +1,14 @@
+var Y = require('Y').Y
+,   Shape = require('ezl/shape/shape').Shape
+,
 
-Circle = new Y.Class('Circle', Shape, {
+Circle =
+exports['Circle'] =
+Shape.subclass('Circle', {
     _cssClasses : 'ezl layer shape circle',
     
     init : function initCircle(radius, centerTL){
-        Layer.init.call(this);
+        Shape.init.call(this);
         
         var d = radius * 2;
         this.radius = radius;
index 956b521..63d3b02 100644 (file)
@@ -1,5 +1,12 @@
+//@require('jquery')
 
-Line = new Y.Class('Line', Shape, {
+var Y = require('Y').Y
+,   Shape = require('ezl/shape/shape').Shape
+,
+
+Line =
+exports['Line'] =
+Shape.subclass('Line', {
     _cssClasses : 'ezl layer shape line',
     
     useCanvasScaling : true,
@@ -12,7 +19,7 @@ Line = new Y.Class('Line', Shape, {
     
     
     init : function initLine(x,y){
-        Layer.init.call(this);
+        Shape.init.call(this);
         
         this.sublayer = jQuery('<div style="overflow:hidden" />')
             .append(this.canvas)
index b61641b..6222886 100644 (file)
@@ -1,4 +1,4 @@
-var Shape = require('ezl/shape').Shape
+var Shape = require('ezl/shape/shape').Shape
 ,
 
 Rect =
index 7b24a8d..1c3aa8c 100644 (file)
@@ -1,4 +1,10 @@
-Shape = new Y.Class('Shape', Layer, {
+var Y = require('Y').Y
+,   Layer = require('ezl/layer').Layer
+,
+
+Shape =
+exports['Shape'] =
+Layer.subclass('Shape', {
     _cssClasses : 'ezl layer shape',
     fillStyle   : 'rgba(231,48,117, 1)',
     strokeStyle : 'transparent',
index 8ff0636..16d6f83 100644 (file)
@@ -1,4 +1,5 @@
-var CAPACITY  = 8
+var Y = require('Y').Y
+,   CAPACITY  = 8
 ,   REGION_ID = 0
 ,
 
index e905a6b..953ca74 100644 (file)
@@ -1,5 +1,7 @@
 //  -*- mode: JavaScript; tab-width: 4; indent-tabs-mode: nil; -*-
-var defaults =
+var Y = require('Y').Y
+
+,   defaults =
 exports.defaults = {
     ui : {
         showGridCoords : false,
@@ -11,4 +13,5 @@ exports.defaults = {
         traceTrajectories : false
     }
 };
+
 exports.values = Y(defaults).clone().end();
index f7a07f5..3f9da2f 100644 (file)
@@ -1,20 +1,28 @@
-var tanks = require('tanks')
-,   map   = require('tanks/map')
-,   thing = require('tanks/thing')
-,   Grid  = require('tanks/ui/grid').Grid
+//@require('lessly/future')
+//@require('jquery')
 
-,   Level = map.Level
-,   Thing = thing.Thing, Tank = thing.Tank, Bullet = thing.Bullet
+var Y         = require('Y').Y
+,   Event     = require('Y/modules/y.event').Event
+,   EventLoop = require('ezl/loop').EventLoop
 
-;
+,   config = require('tanks/config')
+,   map    = require('tanks/map')
+,   thing  = require('tanks/thing')
+,   Grid   = require('tanks/ui/grid').Grid
 
-exports.Game = Y.subclass('Game', {
+,   Level  = map.Level
+,   Thing  = thing.Thing, Tank = thing.Tank, Bullet = thing.Bullet
+,
+
+
+Game =
+exports['Game'] = 
+Y.subclass('Game', {
     overlayPathmap : false,
     
     
-    init : function init(viewport){
+    init : function initGame(viewport){
         Y.bindAll(this);
-        tanks.resetGlobals();
         
         this.byId = {};
         this.active   = new Y.YArray();
@@ -46,14 +54,22 @@ exports.Game = Y.subclass('Game', {
     
     destroy : function destroy(){
         this.stop();
-        tanks.resetGlobals();
+        this.resetGlobals();
+    },
+    
+    resetGlobals : function resetGlobals(){
+        NOW      = new Date().getTime();
+        ELAPSED  = MS_PER_FRAME;
+        TICKS    = 0;
+        SECONDTH = ELAPSED / 1000;
+        SQUARETH = REF_SIZE * SECONDTH;
     },
     
     draw : function draw(){
         this.root.draw();
         
         this.pathmap.removeOverlay(this.viewport);
-        if (tanks.config.values.pathing.overlayPathmap)
+        if (config.values.pathing.overlayPathmap)
             this.pathmap.overlay(this.viewport);
     },
     
@@ -94,7 +110,7 @@ exports.Game = Y.subclass('Game', {
     // *** Agent Management *** //
     
     addUnit : function addUnit(unit, col,row){
-        if (unit instanceof Y.event.YEvent)
+        if (unit instanceof Event)
             unit = unit.instance;
         
         unit.game = this;
@@ -126,7 +142,7 @@ exports.Game = Y.subclass('Game', {
     },
     
     killUnit : function killUnit(unit){
-        if (unit instanceof Y.event.YEvent)
+        if (unit instanceof Event)
             unit = unit.instance;
         
         // console.log('killUnit(', unit, ')');
@@ -190,4 +206,3 @@ exports.Game = Y.subclass('Game', {
     
 });
 
-
similarity index 68%
rename from src/tanks/globals.cjs
rename to src/tanks/globals.js
index 67dfe05..cb949e5 100644 (file)
@@ -1,4 +1,6 @@
+
 var undefined
+,   Y = require('Y').Y
 ,   GRID_ELEMENT  = '#viewport'
 
 ,   REF_SIZE      = 50
@@ -30,23 +32,3 @@ var undefined
 ,   TWO_PI         = PI*2
 
 ;
-
-tanks.resetGlobals = function resetGlobals(){
-    NOW      = new Date().getTime();
-    ELAPSED  = MS_PER_FRAME;
-    TICKS    = 0;
-    
-    SECONDTH = ELAPSED / 1000;
-    SQUARETH = REF_SIZE * SECONDTH;
-};
-
-if (!window.console) {
-    console = {
-        log   : Y.op.nop,
-        info  : Y.op.nop,
-        warn  : Y.op.nop,
-        error : Y.op.nop,
-        dir   : Y.op.nop,
-        debug : Y.op.nop
-    };
-}
index 4b77f3b..b9ac483 100644 (file)
@@ -1,2 +1,24 @@
-var tanks = exports.tanks = {};
-tanks.config = require('tanks/config');
+//@ require('tanks/globals')
+var Y = require('Y').Y;
+
+require('tanks/globals');
+
+tanks = exports.tanks = {
+    'config' : require('tanks/config'),
+    'ui'     : require('tanks/ui'),
+    'Game'   : require('tanks/game').Game,
+    
+    'currentGame' : null,
+    
+};
+
+if (!window.console) {
+    console = {
+        log   : Y.op.nop,
+        info  : Y.op.nop,
+        warn  : Y.op.nop,
+        error : Y.op.nop,
+        dir   : Y.op.nop,
+        debug : Y.op.nop
+    };
+}
index e69de29..7a345f6 100644 (file)
@@ -0,0 +1,8 @@
+var Y = require('Y').Y;
+
+Y.extend(exports, {
+    'Level'      : require('tanks/map/level').Level,
+    'Wall'       : require('tanks/map/wall').Wall,
+    'PathMap'    : require('tanks/map/pathmap').PathMap,
+    'Trajectory' : require('tanks/map/trajectory').Trajectory
+});
index 12a6989..66075d0 100644 (file)
@@ -1,4 +1,14 @@
-Level = Rect.subclass('Level', {
+var Y          = require('Y').Y
+,   Rect       = require('ezl/shape').Rect
+,   Tank       = require('tanks/thing/tank').Tank
+,   PlayerTank = require('tanks/thing/player').PlayerTank
+,   PathMap    = require('tanks/map/pathmap').PathMap
+,
+
+
+Level =
+exports['Level'] =
+Rect.subclass('Level', {
     _cssClasses : 'ezl layer level',
     
     init : function init(game, w,h){
@@ -35,7 +45,7 @@ Level = Rect.subclass('Level', {
     },
     
     addWall : function addWall(x,y, w,h, isBoundary){
-        var wall = new Level.Wall(x,y, w,h, isBoundary);
+        var wall = new Wall(x,y, w,h, isBoundary);
         this.pathmap.addBlocker(wall);
         this.append( wall.render(this).shape );
         
@@ -47,58 +57,4 @@ Level = Rect.subclass('Level', {
     
     drawShape : Y.op.nop
     
-});
-
-Level.Wall = Thing.subclass('Wall', {
-    isBoundary : false,
-    blocking : true,
-    active   : false,
-    
-    stats : {
-        hp    : Infinity,
-        move  : 0,
-        power : 0,
-        speed : 0,
-        shots : 0
-    },
-    
-    
-    init : function initWall(x,y, w,h, isBoundary){
-        this.width = w;
-        this.height = h;
-        this.isBoundary = !!isBoundary;
-        Thing.init.call(this);
-        this.setLocation(x,y);
-    },
-    
-    // inactive
-    createCooldowns : Y.op.nop,
-    
-    // indestructable
-    dealDamage : Y.op.nop,
-    
-    
-    render : function render(parent){
-        if (this.isBoundary)
-            return this;
-        
-        if (this.shape)
-            this.shape.remove();
-        
-        this.shape =
-            new Rect(this.width, this.height)
-                .position(this.loc.x, this.loc.y)
-                .fill('rgba(255,255,255, 0.25)')
-                .appendTo( parent );
-        
-        return this;
-    },
-    
-    toString : function(){
-        var loc = this.loc
-        ,   x1 = loc.x, y1 = loc.y
-        ,   x2 = x1+this.width, y2 = y1 + this.height;
-        return this.className+'['+x1+','+y1+', '+x2+','+y2+'](w='+this.width+', h='+this.height+')';
-    }
-});
-
+});
\ No newline at end of file
index 7284034..afa0177 100644 (file)
@@ -1,9 +1,13 @@
 //  -*- mode: JavaScript; tab-width: 4; indent-tabs-mode: nil; -*-
-(function(){
+var Y = require('Y').Y
+,   QuadTree = require('ezl/util/tree/quadtree').QuadTree
+,
 
-PathMap = QuadTree.subclass('PathMap', {
+PathMap =
+exports['PathMap'] =
+QuadTree.subclass('PathMap', {
     gridSquareSize  : REF_SIZE,
-    gridSquareMidPt : new math.Vec(REF_SIZE/2, REF_SIZE/2),
+    gridSquareMidPt : new Vec(REF_SIZE/2, REF_SIZE/2),
     
     
     
@@ -136,10 +140,10 @@ PathMap = QuadTree.subclass('PathMap', {
             for (var x=0; x<cols; x++) {
                 var col = grid[x] = new Array(rows);
                 for (var y=0; y<rows; y++) {
-                    var node = col[y] = new math.Vec(x,y);
+                    var node = col[y] = new Vec(x,y);
                     
                     node.clone = function cloneNode(){
-                        var n = math.Vec.prototype.clone.call(this);
+                        var n = Vec.prototype.clone.call(this);
                         n.blocked = this.blocked;
                         n.value   = this.value;
                         return n;
@@ -180,7 +184,7 @@ PathMap = QuadTree.subclass('PathMap', {
             x = x.x;
         }
         var floor = Math.floor, size = this.gridSquareSize;
-        return new math.Vec(floor(x/size), floor(y/size));
+        return new Vec(floor(x/size), floor(y/size));
     },
     
     square2Vec : function square2Vec(x,y){
@@ -189,7 +193,7 @@ PathMap = QuadTree.subclass('PathMap', {
             x = x.x;
         }
         var floor = Math.floor, size = this.gridSquareSize;
-        return new math.Vec(floor(x)*size, floor(y)*size);
+        return new Vec(floor(x)*size, floor(y)*size);
     },
     
     path : function path(start, end, id){
@@ -374,5 +378,3 @@ var QT = QuadTree.prototype;
         };
     });
 
-
-})();
index bc39f3d..fa38fc0 100644 (file)
@@ -1,4 +1,14 @@
-Trajectory = math.Line.subclass('Trajectory', {
+var Y     = require('Y').Y
+,   math  = require('ezl/math')
+,   Vec   = math.Vec
+,   Line  = math.Line
+,   Rect  = math.Rect
+,   Thing = require('tanks/thing/thing').Thing
+,
+
+Trajectory =
+exports['Trajectory'] =
+Line.subclass('Trajectory', {
     halt    : false,
     elapsed : 0,
     bounces : 0,
@@ -22,7 +32,7 @@ Trajectory = math.Line.subclass('Trajectory', {
         }
         
         // init with raw numbers to do calculations
-        math.Line.init.call(this, x1,y1, x2,y2, tdist || this.tdist);
+        Line.init.call(this, x1,y1, x2,y2, tdist || this.tdist);
         
         var pm = this.pathmap
         ,   ex = (x1 > x2 ? -REF_SIZE : REF_SIZE+pm.width )
@@ -33,8 +43,8 @@ Trajectory = math.Line.subclass('Trajectory', {
         // Move goal point beyond far wall to avoid rotations
         x2 = this.x2 = edge.x;
         y2 = this.y2 = edge.y;
-        this.p2 = new math.Vec(x2,y2);
-        math.Vec.init.call(this, x2-x1, y2-y1);
+        this.p2 = new Vec(x2,y2);
+        Vec.init.call(this, x2-x1, y2-y1);
         
         this.elapsed = 0;
         this.resetBound();
@@ -58,10 +68,10 @@ Trajectory = math.Line.subclass('Trajectory', {
         if (o instanceof Thing)
             return o.boundingBox.intersects(this);
         
-        if (o instanceof Loc.Rect)
+        if (o instanceof Rect)
             return o.intersects(this);
         
-        return math.Line.prototype.intersects.call(this, x,y);
+        return Line.prototype.intersects.call(this, x,y);
     },
     
     
@@ -163,7 +173,7 @@ Trajectory = math.Line.subclass('Trajectory', {
             if (this.halt) break;
             
             // FIXME: bb.add?
-            bb = new Loc.Rect(to.x,to.y, to.x+bw,to.y+bh);
+            bb = new Rect(to.x,to.y, to.x+bw,to.y+bh);
             
         } while (dt > 0);
         
@@ -224,4 +234,4 @@ Trajectory = math.Line.subclass('Trajectory', {
     toString : function toString(){
         return 'T['+this.p1+', '+this.p2+', slope='+this.slope.toFixed(3)+']';
     }
-});
\ No newline at end of file
+});
diff --git a/src/tanks/map/wall.cjs b/src/tanks/map/wall.cjs
new file mode 100644 (file)
index 0000000..0f79275
--- /dev/null
@@ -0,0 +1,61 @@
+var Y = require('Y').Y
+,   Rect       = require('ezl/shape').Rect
+,   Thing      = require('tanks/thing/thing').Thing
+,
+
+
+Wall =
+exports['Wall'] =
+Thing.subclass('Wall', {
+    isBoundary : false,
+    blocking : true,
+    active   : false,
+    
+    stats : {
+        hp    : Infinity,
+        move  : 0,
+        power : 0,
+        speed : 0,
+        shots : 0
+    },
+    
+    
+    init : function initWall(x,y, w,h, isBoundary){
+        this.width = w;
+        this.height = h;
+        this.isBoundary = !!isBoundary;
+        Thing.init.call(this);
+        this.setLocation(x,y);
+    },
+    
+    // inactive
+    createCooldowns : Y.op.nop,
+    
+    // indestructable
+    dealDamage : Y.op.nop,
+    
+    
+    render : function render(parent){
+        if (this.isBoundary)
+            return this;
+        
+        if (this.shape)
+            this.shape.remove();
+        
+        this.shape =
+            new Rect(this.width, this.height)
+                .position(this.loc.x, this.loc.y)
+                .fill('rgba(255,255,255, 0.25)')
+                .appendTo( parent );
+        
+        return this;
+    },
+    
+    toString : function(){
+        var loc = this.loc
+        ,   x1 = loc.x, y1 = loc.y
+        ,   x2 = x1+this.width, y2 = y1 + this.height;
+        return this.className+'['+x1+','+y1+', '+x2+','+y2+'](w='+this.width+', h='+this.height+')';
+    }
+});
+
index 2dc640d..89d2a89 100644 (file)
@@ -1,5 +1,15 @@
 //  -*- mode: JavaScript; tab-width: 4; indent-tabs-mode: nil; -*-
-Bullet = Thing.subclass('Bullet', {
+var Y      = require('Y').Y
+,   shape  = require('ezl/shape')
+,   Wall   = require('tanks/map/wall').Wall
+,   Thing  = require('tanks/thing/thing').Thing
+,   Line   = shape.Line
+,   Circle = shape.Circle
+,
+
+Bullet =
+exports['Bullet'] =
+Thing.subclass('Bullet', {
     traceTrajectories : true,
     
     
@@ -78,7 +88,7 @@ Bullet = Thing.subclass('Bullet', {
         var agent = evt.trigger
         ,   trj = this.trajectory;
         
-        if ( agent instanceof Level.Wall && trj.bounces <= this.bounceLimit )
+        if ( agent instanceof Wall && trj.bounces <= this.bounceLimit )
             return;
         
         agent.dealDamage(this.stats.power, this);
similarity index 58%
rename from src/tanks/thing/custom-tank.cjs
rename to src/tanks/thing/customtank.cjs
index c9a7267..97dcecf 100644 (file)
@@ -1,8 +1,13 @@
-CustomTank = Tank.subclass('CustomTank', {
+var Tank  = require('tanks/thing/tank').Tank
+,
+
+CustomTank =
+exports['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 34bd5c2..43a7d85 100644 (file)
@@ -1,5 +1,5 @@
-exports.Thing      = require('tanks/thing/thing').Thing;
-exports.Bullet     = require('tanks/thing/bullet').Bullet;
-exports.Tank       = require('tanks/thing/tank').Tank;
-exports.PlayerTank = require('tanks/thing/player').PlayerTank;
-
+exports['Thing']      = require('tanks/thing/thing').Thing;
+exports['Bullet']     = require('tanks/thing/bullet').Bullet;
+exports['Tank']       = require('tanks/thing/tank').Tank;
+exports['PlayerTank'] = require('tanks/thing/player').PlayerTank;
+// exports['CustomTank'] = require('tanks/thing/customtank').CustomTank;
index 26d276c..7dd5775 100644 (file)
@@ -1,6 +1,13 @@
+//@require('jquery')
+//@require('jquery.hotkeys.min')
 
-var PlayerTank =
-exports.PlayerTank =
+var Y    = require('Y').Y
+,   Tank = require('tanks/thing/tank').Tank
+,
+
+
+PlayerTank =
+exports['PlayerTank'] =
 Tank.subclass('PlayerTank', {
     
     bodyColor   : '#E73075',
@@ -172,10 +179,11 @@ Tank.subclass('PlayerTank', {
         this.rotateBarrelRelPage(evt.pageX, evt.pageY);
     }
     
-});
-
+})
+,
 
-var Key = {
+Key = 
+exports['Key'] = {
     fire : 32,
     
     _dirFromKey : {
index 543d456..34c1644 100644 (file)
@@ -1,11 +1,20 @@
-(function(){
+var Y          = require('Y').Y
+,   Thing      = require('tanks/thing/thing').Thing
+,   Bullet     = require('tanks/thing/bullet').Bullet
+,   Trajectory = require('tanks/map/trajectory').Trajectory
+,   Vec        = require('ezl/math/vec').Vec
+,   shape      = require('ezl/shape')
+,   Rect       = shape.Rect
+,   Circle     = shape.Circle
 
-var BULLET_MOVE_PER_FRAME = MS_PER_FRAME * Bullet.prototype.stats.move*REF_SIZE/1000
 ,   isBullet = Y.is(Bullet)
-;
+,   BULLET_MOVE_PER_FRAME = MS_PER_FRAME * Bullet.prototype.stats.move*REF_SIZE/1000
+,
 
 
-Tank = Thing.subclass('Tank', {
+Tank =
+exports['Tank'] =
+Thing.subclass('Tank', {
     projectile : Bullet,
     blocking : true,
     
@@ -420,5 +429,3 @@ Tank = Thing.subclass('Tank', {
     
 });
 
-
-})();
\ No newline at end of file
index c29f1e0..d269d3f 100644 (file)
@@ -1,11 +1,15 @@
-var loc      = require('tanks/map/loc')
-,   Cooldown = require('ezl/loop/cooldown').Cooldown
-,   Loc = loc.Loc, BoundingBox = loc.BoundingBox
-;
+var Y           = require('Y').Y
+,   Class       = require('evt/class').Class
 
-var Thing =
-exports.Thing =
-new Evt.Class('Thing', {
+,   Loc         = require('ezl/loc/loc').Loc
+,   BoundingBox = require('ezl/loc/boundingbox').BoundingBox
+,   Cooldown    = require('ezl/loop').Cooldown
+,
+
+
+Thing =
+exports['Thing'] =
+new Class('Thing', {
     
     init : function init(align){
         this.id    = Thing.THING_ID++;
similarity index 90%
rename from src/tanks/ui/ui-config.cjs
rename to src/tanks/ui/config.cjs
index c32d26b..0c443d7 100644 (file)
@@ -1,4 +1,5 @@
-(function(){
+//@require('jquery')
+
 
 // TODO
 // ====
 // - If different from default, set cookie
 // - Update tanks.config.values
 
-
-var ns = tanks.ui.config = {}
-,   c = tanks.config.values
+var Y = require('Y').Y
+,   config = require('tanks/config')
+,   c = config.values
 ,   p = c.pathing
 ;
 
 
 
 
-ns.init = function initConfigUi(){
+exports['init'] = function initConfigUi(){
     $('#config [name=pathmap]').attr('checked', p.overlayPathmap);
     $('#config [name=aipaths]').attr('checked', p.overlayAIPaths);
     $('#config [name=trajectories]').attr('checked', p.traceTrajectories);
@@ -35,7 +36,7 @@ ns.init = function initConfigUi(){
     $('#viewport .layer.grid')[(c.ui.showGridCoords ? 'add' : 'remove')+'Class']('showGridCoords');
 };
 
-ns.update = function updateConfigUi(evt){
+exports['update'] = function updateConfigUi(evt){
     p.overlayPathmap    = $('#config [name=pathmap]').attr('checked');
     p.overlayAIPaths    = $('#config [name=aipaths]').attr('checked');
     p.traceTrajectories = $('#config [name=trajectories]').attr('checked');
@@ -66,7 +67,7 @@ ns.update = function updateConfigUi(evt){
 //     // 'Function'
 //     // 'Object'
 // };
-// ns.makeField = function makeField(key, value){
+// exports['makeField'] = function makeField(key, value){
 //     
 // };
 
@@ -85,6 +86,3 @@ Y.YString.prototype.splitCamel =
             .split(' ');
     };
 
-
-
-})();
index 55c391b..5183abf 100644 (file)
@@ -1,4 +1,10 @@
-Grid = new Y.Class('Grid', Rect, {
+var Y = require('Y').Y
+,   Rect = require('ezl/shape').Rect
+,
+
+Grid =
+exports['Grid'] =
+Rect.subclass('Grid', {
     _cssClasses : 'ezl layer shape rect grid',
     
     lineWidth : 0.5,
@@ -63,4 +69,4 @@ Grid = new Y.Class('Grid', Rect, {
         }
     }
     
-});
\ No newline at end of file
+});
index e69de29..9fe937d 100644 (file)
@@ -0,0 +1,3 @@
+var Y = require('Y').Y;
+Y.extend(exports, require('tanks/ui/config'));
+exports['main'] = require('tanks/ui/main');
index 7f697b2..acdff0f 100644 (file)
@@ -1,13 +1,21 @@
-(function(){
+//@require('jquery')
+//@require('jquery.hotkeys.min')
 
-jQuery(main);
+var Y            = require('Y').Y
+,   config       = require('tanks/config')
+,   uiconfig     = require('tanks/ui/config')
+,   Game         = require('tanks/game').Game
+,   Tank         = require('tanks/thing').Tank
+,   FpsSparkline = require('ezl/loop').FpsSparkline
+;
+
+qkv = Y(window.location.search.slice(1)).fromKV().end();
 
-this.main = main;
+jQuery(main);
 
 // Main method is only executed once, so we'll setup things
 // that don't change between games.
 function main(){
-    qkv = Y(window.location.search.slice(1)).fromKV().end();
     
     /// Debug ///
     if (qkv.ai) {
@@ -19,7 +27,7 @@ function main(){
     
     $('#ai .ready').bind('click', function(evt){
         try {
-            var script = $('#custom-tank').val();
+            var script = $('#customtank').val();
             Tank.prototype.act = eval('(function(){ with(this){'+script+'} })');
             $('#ai').hide();
             startGame();
@@ -35,7 +43,7 @@ function main(){
     $('#debug').bind('mousedown', Y.op.K(false));
     
     // Update config when changed
-    $('#debug input').bind('change', tanks.ui.config.update);
+    $('#debug input').bind('change', uiconfig.update);
     
     
     // Create #pause box
@@ -72,7 +80,7 @@ function gameExists(){ return !!tanks.currentGame; }
 function setupGame(){
     if ( gameExists() ) teardownGame();
     
-    LBT = tanks.currentGame = new tanks.Game();
+    LBT = tanks.currentGame = new Game();
     
     LBT.addEventListener('win',  gameover('You Win!', 'Play Again', ''));
     LBT.addEventListener('lose', gameover('You Lose :(', 'Try Again', ''));
@@ -92,7 +100,7 @@ function setupUI(){
     
     if (!qkv.ai) $('#welcome').show();
     LBT.loop.spark = new FpsSparkline(LBT.loop, '.fps-sparkline', 0,0);
-    tanks.ui.config.init();
+    uiconfig.init();
     LBT.root.draw();
     
     // Start button (click or return key)
@@ -124,8 +132,8 @@ function startGame(evt){
     
     $('#welcome').hide();
     
-    if ( tanks.config.values.ui.showCountdown )
-        countdownToStart(3, readyToStart);
+    if ( config.values.ui.showCountdown )
+        countdown(3, readyToStart);
     else
         readyToStart();
 }
@@ -165,7 +173,7 @@ function gameover(headline, button, body, evt){
 gameover = Y(gameover).curry();
 
 
-function countdownToStart(n, fn){
+function countdown(n, fn){
     var el
     ,   showFor  = 750
     ,   pauseFor = 500
@@ -245,6 +253,19 @@ function updateInfo(){
 }
 
 
-
-}).call(tanks.ui);
+exports['main']         = main;
+exports['gameExists']   = gameExists;
+exports['setupGame']    = setupGame;
+exports['teardownGame'] = teardownGame;
+exports['setupUI']      = setupUI;
+exports['teardownUI']   = teardownUI;
+exports['startGame']    = startGame;
+exports['pauseGame']    = pauseGame;
+exports['toggleGame']   = toggleGame;
+exports['resizeGame']   = resizeGame;
+exports['gameover']     = gameover;
+exports['countdown']    = countdown;
+exports['tickDown']     = tickDown;
+exports['readyToStart'] = readyToStart;
+exports['updateInfo']   = updateInfo;
 
diff --git a/src/tanks/ui/ui.cjs b/src/tanks/ui/ui.cjs
deleted file mode 100644 (file)
index a1ca700..0000000
+++ /dev/null
@@ -1 +0,0 @@
-tanks.ui = {};
index 822e579..f4b319d 100644 (file)
@@ -1,11 +1,18 @@
-Config = Y.YObject.subclass('Config', function(){
+var Y = require('Y').Y
+,   Emitter = require('Y/modules/y.event').Emitter
+,
+
+
+Config =
+exports.Config =
+Y.YObject.subclass('Config', function(){
     
     Y.op.extend(this, {
         
         init : function initConfig(defaults){
             this._defaults = defaults;
             this._o = Y({}, defaults);
-            this.__emitter__ = new Y.event.Emitter(this);
+            this.__emitter__ = new Emitter(this);
         },
         
         set : function set(key, value, def){
@@ -90,4 +97,4 @@ Config = Y.YObject.subclass('Config', function(){
         
     });
     
-});
\ No newline at end of file
+});
diff --git a/tags.php b/tags.php
new file mode 100644 (file)
index 0000000..f9e48c9
--- /dev/null
+++ b/tags.php
@@ -0,0 +1,58 @@
+<script src="build/lessly/future.js" type="text/javascript"></script>
+<script src="build/functional/to-function.js" type="text/javascript"></script>
+<script src="build/jquery.js" type="text/javascript"></script>
+<script src="build/jquery.sparkline.min.js" type="text/javascript"></script>
+<script src="build/jquery.hotkeys.min.js" type="text/javascript"></script>
+<script src="build/Y/type.js" type="text/javascript"></script>
+<script src="build/Y/core.js" type="text/javascript"></script>
+<script src="build/Y/y.js" type="text/javascript"></script>
+<script src="build/Y/types/function.js" type="text/javascript"></script>
+<script src="build/Y/op.js" type="text/javascript"></script>
+<script src="build/Y/class.js" type="text/javascript"></script>
+<script src="build/Y/utils.js" type="text/javascript"></script>
+<script src="build/Y/types/collection.js" type="text/javascript"></script>
+<script src="build/Y/types/object.js" type="text/javascript"></script>
+<script src="build/Y/types/number.js" type="text/javascript"></script>
+<script src="build/Y/types/string.js" type="text/javascript"></script>
+<script src="build/Y/types/array.js" type="text/javascript"></script>
+<script src="build/Y.js" type="text/javascript"></script>
+<script src="build/ezl/loop/cooldown.js" type="text/javascript"></script>
+<script src="build/tanks/globals.js" type="text/javascript"></script>
+<script src="build/Y/modules/y.event.js" type="text/javascript"></script>
+<script src="build/ezl/math/vec.js" type="text/javascript"></script>
+<script src="build/ezl/math/rect.js" type="text/javascript"></script>
+<script src="build/tanks/config.js" type="text/javascript"></script>
+<script src="build/ezl/loc/loc.js" type="text/javascript"></script>
+<script src="build/ezl/loop/fps.js" type="text/javascript"></script>
+<script src="build/ezl/util/tree/quadtree.js" type="text/javascript"></script>
+<script src="build/ezl/math/line.js" type="text/javascript"></script>
+<script src="build/ezl/loop/eventloop.js" type="text/javascript"></script>
+<script src="build/ezl/loop.js" type="text/javascript"></script>
+<script src="build/tanks/ui/config.js" type="text/javascript"></script>
+<script src="build/evt/class.js" type="text/javascript"></script>
+<script src="build/tanks/map/pathmap.js" type="text/javascript"></script>
+<script src="build/ezl/math.js" type="text/javascript"></script>
+<script src="build/ezl/loc/boundingbox.js" type="text/javascript"></script>
+<script src="build/ezl/loc/square.js" type="text/javascript"></script>
+<script src="build/ezl/loc.js" type="text/javascript"></script>
+<script src="build/tanks/thing/thing.js" type="text/javascript"></script>
+<script src="build/ezl/layer.js" type="text/javascript"></script>
+<script src="build/ezl/shape/shape.js" type="text/javascript"></script>
+<script src="build/tanks/map/trajectory.js" type="text/javascript"></script>
+<script src="build/ezl/shape/line.js" type="text/javascript"></script>
+<script src="build/ezl/shape/circle.js" type="text/javascript"></script>
+<script src="build/ezl/shape/rect.js" type="text/javascript"></script>
+<script src="build/ezl/shape/polygon.js" type="text/javascript"></script>
+<script src="build/ezl/shape.js" type="text/javascript"></script>
+<script src="build/tanks/ui/grid.js" type="text/javascript"></script>
+<script src="build/tanks/map/wall.js" type="text/javascript"></script>
+<script src="build/tanks/thing/bullet.js" type="text/javascript"></script>
+<script src="build/tanks/thing/tank.js" type="text/javascript"></script>
+<script src="build/tanks/thing/player.js" type="text/javascript"></script>
+<script src="build/tanks/map/level.js" type="text/javascript"></script>
+<script src="build/tanks/thing.js" type="text/javascript"></script>
+<script src="build/tanks/map.js" type="text/javascript"></script>
+<script src="build/tanks/game.js" type="text/javascript"></script>
+<script src="build/tanks/ui/main.js" type="text/javascript"></script>
+<script src="build/tanks/ui.js" type="text/javascript"></script>
+<script src="build/tanks.js" type="text/javascript"></script>
index e88b37d..da77d84 100644 (file)
--- a/tanks.php
+++ b/tanks.php
@@ -12,7 +12,8 @@ class Tanks {
     const BUILD_DIR = "build";
     
     static $modules = array(
-        array( "main" => "src/Y/index.cjs", "loader" => "y-loader.js" )
+        // array( "main" => "src/Y/index.cjs", "loader" => "y-loader.js" )
+        array( "main" => "src/tanks/index.cjs", "loader" => "tanks-loader.js" )
     );
     
     
@@ -32,7 +33,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/customtank.js",
         "src/tanks/thing/player.js",
         
         "src/tanks/map/loc.js",
@@ -42,7 +43,7 @@ class Tanks {
         
         "src/tanks/ui/ui.js",
         "src/tanks/ui/grid.js",
-        "src/tanks/ui/ui-config.js",
+        "src/tanks/ui/config.js",
         
         "src/tanks/game.js"
     );
@@ -102,13 +103,14 @@ class Tanks {
     static function compile($modules=null) {
         $modules = ($modules ? $modules : self::$modules);
         $PYTHONPATH = "PYTHONPATH='/Users/dsc/.python/lib/python:/usr/local/lib/python2.7/site-packages:/usr/local/lib/python2.6/site-packages'";
-        // error_reporting(E_ALL);
-        // echo "<!--";
+        error_reporting(E_ALL);
+        echo "<!--";
         foreach ($modules as $module) {
-            $ret = shell_exec("$PYTHONPATH bin/cjs.py -s {$module['main']} -- src lib 2>&1");
+            $ret = shell_exec("$PYTHONPATH bin/cjs.py {$module['main']} -- src lib 2>&1"); //
             echo "    ".trim(join("\n    ", split("\n", $ret)));
         }
-        // echo "-->";
+        echo "-->";
+        include "tags.php";
     }
     
     static function writeLoaders($modules=null, $recompile=true){