Permalink
Browse files

Updating gitignore, adding build automation with Grunt, adding Expres…

…s support to the example (CreateJS causes crossdomain issues when run locally), added LICENSE file, updated README with roadmap, added package.json, restructured directory to be more js-like.
  • Loading branch information...
1 parent 67c3bf3 commit 7d3b04d28efd49a5917f639d23c8e339ecb3c071 Bryce Neal committed May 16, 2013
View
@@ -1 +1,2 @@
-.DS_Store
+.DS_Store
+node_modules/
View
@@ -0,0 +1,19 @@
+module.exports = function(grunt) {
+ // Project configuration.
+ grunt.initConfig({
+ uglify: {
+ release: {
+ files: {}
+ }
+ }
+ });
+
+ var releaseFilename = "easystar-" + grunt.file.readJSON('package.json').version + ".min.js";
+ var files = {};
+ files[releaseFilename] = ['lib/node.js', 'lib/priorityqueue.js', 'lib/easystar.js'];
+ grunt.config.set('uglify.release.files',files)
+
+ // Load the plugin that provides the "uglify" task.
+ grunt.loadNpmTasks('grunt-contrib-uglify');
+
+};
View
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2012-2013 Bryce Neal
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
@@ -1,6 +1 @@
-var EasyStar=EasyStar||{};EasyStar.Node=function(e,k,b,l,c){this.parent=e;this.x=k;this.y=b;this.costSoFar=l;this.simpleDistanceToTarget=c;this.bestGuessDistance=function(){return this.costSoFar+this.simpleDistanceToTarget}};EasyStar.Node.OPEN_LIST=0;EasyStar.Node.CLOSED_LIST=1;EasyStar.PriorityQueue=function(e,k){this.length=0;var b=[],l=!1;if(k==EasyStar.PriorityQueue.MAX_HEAP)l=!0;else if(k==EasyStar.PriorityQueue.MIN_HEAP)l=!1;else throw k+" not supported.";this.insert=function(a){if(!a.hasOwnProperty(e))throw"Cannot insert "+a+" because it does not have a property by the name of "+e+".";b.push(a);this.length++;c(this.length-1)};this.getHighestPriorityElement=function(){return b[0]};this.shiftHighestPriorityElement=function(){if(0===this.length)throw"There are no more elements in your priority queue.";
-if(1===this.length){var a=b[0];b=[];return a}var a=b[0],n=b.pop();this.length--;b[0]=n;g(0);return a};var c=function(a){if(0!==a){var b=Math.floor(a/2)-1;h(a,b)&&(f(a,b),c(b))}},g=function(a){left=2*a+1;right=2*a+2;h(left,a)?(f(a,left),g(left)):h(right,a)?(f(a,right),g(right)):0!=a&&g(0)},f=function(a,c){var e=b[a];b[a]=b[c];b[c]=e},h=function(a,c){if(void 0===b[c]||void 0===b[a])return!1;"function"===typeof b[a][e]?(selfValue=b[a][e](),targetValue=b[c][e]()):(selfValue=b[a][e],targetValue=b[c][e]);
-return l?selfValue>targetValue?!0:!1:selfValue<targetValue?!0:!1}};EasyStar.PriorityQueue.MAX_HEAP=0;EasyStar.PriorityQueue.MIN_HEAP=1;EasyStar.js=function(e,k){var b=!0,l={},c,g,f,h,a,n,q={},p,s=Number.MAX_VALUE;this.setGrid=function(a){c=a};this.setPath=function(i,d,j,l){p=new EasyStar.PriorityQueue("bestGuessDistance",EasyStar.PriorityQueue.MIN_HEAP);b=!0;q={};f=i;h=d;a=j;n=l;if(void 0===c)throw"You can't set a path without first calling setCollisionGrid on the EasyStar.js";if(0>f||0>h||0>a||0>a||f>c[0].length-1||h>c.length-1||a>c[0].length-1||n>c.length-1)throw"Your start or end point is outside the scope of your grid.";f===
-a&&h===n&&k([]);i=c[n][a];d=!1;for(j=0;j<e.length;j++)if(i===e[j]){d=!0;break}!1===d?k(null):(b=!1,p.insert(t(f,h,null,10)))};this.calculate=function(){if(!(void 0===c||!0===b))for(g=0;g<s;){if(0===p.length){k(null);b=!0;break}var a=p.shiftHighestPriorityElement();a.list=EasyStar.Node.CLOSED_LIST;if(0<a.y&&(r(a,0,-1,10),!0===b))break;if(a.x<c[0].length-1&&(r(a,1,0,10),!0===b))break;if(a.y<c.length-1&&(r(a,0,1,10),!0===b))break;if(0<a.x&&(r(a,-1,0,10),!0===b))break;g++}};this.setIterationsPerCalculation=
-function(a){s=a};this.setAcceptableTiles=function(a){e=a};this.avoidAdditionalPoint=function(a,b){l[a+"_"+b]=1};var r=function(i,d,j,h){d=i.x+d;j=i.y+j;if(a===d&&n===j){b=!0;var m=[],f=0;m[f]={x:d,y:j};f++;m[f]={x:i.x,y:i.y};f++;for(var g=i.parent;null!=g;)m[f]={x:g.x,y:g.y},f++,g=g.parent;m.reverse();k(m)}if(void 0===l[d+"_"+j])for(m=0;m<e.length;m++)if(c[j][d]===e[m]){d=t(d,j,i,h);void 0===d.list?(d.list=EasyStar.Node.OPEN_LIST,p.insert(d)):d.list===EasyStar.Node.OPEN_LIST&&i.costSoFar+h<d.costSoFar&&
-(d.costSoFar=i.costSoFar+h,d.parent=i);break}},t=function(b,d,c,e){if(void 0!==q[b+"_"+d])return q[b+"_"+d];var f=Math.floor(Math.abs(d-b)+Math.abs(n-a)),c=new EasyStar.Node(c,b,d,null!==c?c.costSoFar+e:f,f);return q[b+"_"+d]=c}};
+var EasyStar=EasyStar||{};EasyStar.Node=function(t,e,r,i,n){this.parent=t,this.x=e,this.y=r,this.costSoFar=i,this.simpleDistanceToTarget=n,this.bestGuessDistance=function(){return this.costSoFar+this.simpleDistanceToTarget}},EasyStar.Node.OPEN_LIST=0,EasyStar.Node.CLOSED_LIST=1,EasyStar.PriorityQueue=function(t,e){this.length=0;var r=[],i=!1;if(e==EasyStar.PriorityQueue.MAX_HEAP)i=!0;else{if(e!=EasyStar.PriorityQueue.MIN_HEAP)throw e+" not supported.";i=!1}this.insert=function(e){if(!e.hasOwnProperty(t))throw"Cannot insert "+e+" because it does not have a property by the name of "+t+".";r.push(e),this.length++,n(this.length-1)},this.getHighestPriorityElement=function(){return r[0]},this.shiftHighestPriorityElement=function(){if(0===this.length)throw"There are no more elements in your priority queue.";if(1===this.length){var t=r[0];return r=[],this.length=0,t}var e=r[0],i=r.pop();return this.length--,r[0]=i,a(0),e};var n=function(t){if(0!==t){var e=u(t);s(t,e)&&(o(t,e),n(e))}},a=function(t){if(left=l(t),right=h(t),s(left,t))o(t,left),a(left);else if(s(right,t))o(t,right),a(right);else{if(0==t)return;a(0)}},o=function(t,e){var i=r[t];r[t]=r[e],r[e]=i},s=function(e,n){return void 0===r[n]||void 0===r[e]?!1:("function"==typeof r[e][t]?(selfValue=r[e][t](),targetValue=r[n][t]()):(selfValue=r[e][t],targetValue=r[n][t]),i?selfValue>targetValue?!0:!1:targetValue>selfValue?!0:!1)},u=function(t){return Math.floor(t/2)-1},l=function(t){return 2*t+1},h=function(t){return 2*t+2}},EasyStar.PriorityQueue.MAX_HEAP=0,EasyStar.PriorityQueue.MIN_HEAP=1,EasyStar.js=function(t,e){var r,i,n,a,o,s,u,l=10,h=!0,f={},c={},y=Number.MAX_VALUE;this.setGrid=function(t){r=t},this.setPath=function(i,f,y,g){if(u=new EasyStar.PriorityQueue("bestGuessDistance",EasyStar.PriorityQueue.MIN_HEAP),h=!0,c={},n=i,a=f,o=y,s=g,void 0===r)throw"You can't set a path without first calling setCollisionGrid on the EasyStar.js";if(0>n||0>a||0>o||0>o||n>r[0].length-1||a>r.length-1||o>r[0].length-1||s>r.length-1)throw"Your start or end point is outside the scope of your grid.";n===o&&a===s&&e([]);for(var E=r[s][o],S=!1,d=0;t.length>d;d++)if(E===t[d]){S=!0;break}return S===!1?(e(null),void 0):(h=!1,u.insert(v(n,a,null,l)),void 0)},this.calculate=function(){if(void 0!==r&&h!==!0)for(i=0;y>i;){if(0===u.length)return e(null),h=!0,void 0;var t=u.shiftHighestPriorityElement();if(t.list=EasyStar.Node.CLOSED_LIST,t.y>0&&(g(t,0,-1,l),h===!0))return;if(t.x<r[0].length-1&&(g(t,1,0,l),h===!0))return;if(t.y<r.length-1&&(g(t,0,1,l),h===!0))return;if(t.x>0&&(g(t,-1,0,l),h===!0))return;i++}},this.setIterationsPerCalculation=function(t){y=t},this.setAcceptableTiles=function(e){t=e},this.avoidAdditionalPoint=function(t,e){f[t+"_"+e]=1};var g=function(i,n,a,l){var c=i.x+n,y=i.y+a;if(o===c&&s===y){h=!0;var g=[],E=0;g[E]={x:c,y:y},E++,g[E]={x:i.x,y:i.y},E++;for(var S=i.parent;null!=S;)g[E]={x:S.x,y:S.y},E++,S=S.parent;g.reverse(),e(g)}if(void 0===f[c+"_"+y])for(var d=0;t.length>d;d++)if(r[y][c]===t[d]){var P=v(c,y,i,l);void 0===P.list?(P.list=EasyStar.Node.OPEN_LIST,u.insert(P)):P.list===EasyStar.Node.OPEN_LIST&&i.costSoFar+l<P.costSoFar&&(P.costSoFar=i.costSoFar+l,P.parent=i);break}},v=function(t,e,r,i){if(void 0!==c[t+"_"+e])return c[t+"_"+e];var n=E(t,e,o,s);if(null!==r)var a=r.costSoFar+i;else a=n;var u=new EasyStar.Node(r,t,e,a,n);return c[t+"_"+e]=u,u},E=function(t,e,r,i){return Math.floor(Math.abs(e-t)+Math.abs(i-r))}};
View
@@ -0,0 +1,22 @@
+var express = require("express"),
+ app = express(),
+ port = parseInt(process.env.PORT, 10) || 3000;
+
+app.get("/", function(req, res) {
+ res.redirect("/example.html");
+});
+
+app.configure(function(){
+ app.use(express.methodOverride());
+ app.use(express.bodyParser());
+ app.use(express.static(__dirname + '/static'));
+ app.use(express.errorHandler({
+ dumpExceptions: true,
+ showStack: true
+ }));
+ app.use(app.router);
+});
+
+app.listen(port);
+
+console.log("Please visit 127.0.0.1:3000 to view the example.")
@@ -0,0 +1,7 @@
+{
+ "name": "easystarjs-example",
+ "version": "0.1.0",
+ "devDependencies": {
+ "express": "~3.2.4"
+ }
+}
File renamed without changes
@@ -1,8 +1,8 @@
<html>
<head>
- <script type="text/javascript" src="lib/easeljs-0.5.0.min.js"></script>
- <script type="text/javascript" src="lib/tweenjs-0.3.0.min.js"></script>
- <script type="text/javascript" src="../easystar-0.1.0.min.js"></script>
+ <script type="text/javascript" src="/js/easeljs-0.5.0.min.js"></script>
+ <script type="text/javascript" src="/js/tweenjs-0.3.0.min.js"></script>
+ <script type="text/javascript" src="/js/easystar-0.1.0.min.js"></script>
<script type="text/javascript">
//Set up some consts
var TILE_SIZE = 32;
@@ -0,0 +1 @@
+var EasyStar=EasyStar||{};EasyStar.Node=function(t,e,r,i,n){this.parent=t,this.x=e,this.y=r,this.costSoFar=i,this.simpleDistanceToTarget=n,this.bestGuessDistance=function(){return this.costSoFar+this.simpleDistanceToTarget}},EasyStar.Node.OPEN_LIST=0,EasyStar.Node.CLOSED_LIST=1,EasyStar.PriorityQueue=function(t,e){this.length=0;var r=[],i=!1;if(e==EasyStar.PriorityQueue.MAX_HEAP)i=!0;else{if(e!=EasyStar.PriorityQueue.MIN_HEAP)throw e+" not supported.";i=!1}this.insert=function(e){if(!e.hasOwnProperty(t))throw"Cannot insert "+e+" because it does not have a property by the name of "+t+".";r.push(e),this.length++,n(this.length-1)},this.getHighestPriorityElement=function(){return r[0]},this.shiftHighestPriorityElement=function(){if(0===this.length)throw"There are no more elements in your priority queue.";if(1===this.length){var t=r[0];return r=[],this.length=0,t}var e=r[0],i=r.pop();return this.length--,r[0]=i,a(0),e};var n=function(t){if(0!==t){var e=u(t);s(t,e)&&(o(t,e),n(e))}},a=function(t){if(left=l(t),right=h(t),s(left,t))o(t,left),a(left);else if(s(right,t))o(t,right),a(right);else{if(0==t)return;a(0)}},o=function(t,e){var i=r[t];r[t]=r[e],r[e]=i},s=function(e,n){return void 0===r[n]||void 0===r[e]?!1:("function"==typeof r[e][t]?(selfValue=r[e][t](),targetValue=r[n][t]()):(selfValue=r[e][t],targetValue=r[n][t]),i?selfValue>targetValue?!0:!1:targetValue>selfValue?!0:!1)},u=function(t){return Math.floor(t/2)-1},l=function(t){return 2*t+1},h=function(t){return 2*t+2}},EasyStar.PriorityQueue.MAX_HEAP=0,EasyStar.PriorityQueue.MIN_HEAP=1,EasyStar.js=function(t,e){var r,i,n,a,o,s,u,l=10,h=!0,f={},c={},y=Number.MAX_VALUE;this.setGrid=function(t){r=t},this.setPath=function(i,f,y,g){if(u=new EasyStar.PriorityQueue("bestGuessDistance",EasyStar.PriorityQueue.MIN_HEAP),h=!0,c={},n=i,a=f,o=y,s=g,void 0===r)throw"You can't set a path without first calling setCollisionGrid on the EasyStar.js";if(0>n||0>a||0>o||0>o||n>r[0].length-1||a>r.length-1||o>r[0].length-1||s>r.length-1)throw"Your start or end point is outside the scope of your grid.";n===o&&a===s&&e([]);for(var E=r[s][o],S=!1,d=0;t.length>d;d++)if(E===t[d]){S=!0;break}return S===!1?(e(null),void 0):(h=!1,u.insert(v(n,a,null,l)),void 0)},this.calculate=function(){if(void 0!==r&&h!==!0)for(i=0;y>i;){if(0===u.length)return e(null),h=!0,void 0;var t=u.shiftHighestPriorityElement();if(t.list=EasyStar.Node.CLOSED_LIST,t.y>0&&(g(t,0,-1,l),h===!0))return;if(t.x<r[0].length-1&&(g(t,1,0,l),h===!0))return;if(t.y<r.length-1&&(g(t,0,1,l),h===!0))return;if(t.x>0&&(g(t,-1,0,l),h===!0))return;i++}},this.setIterationsPerCalculation=function(t){y=t},this.setAcceptableTiles=function(e){t=e},this.avoidAdditionalPoint=function(t,e){f[t+"_"+e]=1};var g=function(i,n,a,l){var c=i.x+n,y=i.y+a;if(o===c&&s===y){h=!0;var g=[],E=0;g[E]={x:c,y:y},E++,g[E]={x:i.x,y:i.y},E++;for(var S=i.parent;null!=S;)g[E]={x:S.x,y:S.y},E++,S=S.parent;g.reverse(),e(g)}if(void 0===f[c+"_"+y])for(var d=0;t.length>d;d++)if(r[y][c]===t[d]){var P=v(c,y,i,l);void 0===P.list?(P.list=EasyStar.Node.OPEN_LIST,u.insert(P)):P.list===EasyStar.Node.OPEN_LIST&&i.costSoFar+l<P.costSoFar&&(P.costSoFar=i.costSoFar+l,P.parent=i);break}},v=function(t,e,r,i){if(void 0!==c[t+"_"+e])return c[t+"_"+e];var n=E(t,e,o,s);if(null!==r)var a=r.costSoFar+i;else a=n;var u=new EasyStar.Node(r,t,e,a,n);return c[t+"_"+e]=u,u},E=function(t,e,r,i){return Math.floor(Math.abs(e-t)+Math.abs(i-r))}};
File renamed without changes.
File renamed without changes.
File renamed without changes.
View
@@ -0,0 +1,10 @@
+{
+ "name": "easystarjs",
+ "version": "0.1.0",
+ "devDependencies": {
+ "chai": "~1.6.0",
+ "mocha": "~1.9.0",
+ "grunt": "~0.4.1",
+ "grunt-contrib-uglify": "~0.2.0"
+ }
+}

0 comments on commit 7d3b04d

Please sign in to comment.