Created
August 5, 2011 21:31
-
-
Save odoe/1128568 to your computer and use it in GitHub Desktop.
Geo-Game Tile Generation in JavaScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// still very rough | |
var enemyFactory = function(location) { | |
var rand1 = Math.floor(Math.random()*10); | |
var rand2 = Math.floor(Math.random()*10); | |
var add = function(a, b) {return a+b;}; | |
var subtract = function(a ,b) {return a-b;}; | |
var op = [add, subtract]; | |
var r1 = Math.floor(Math.random()*2); | |
var r2 = Math.floor(Math.random()*2); | |
console.log("rand1", rand1); | |
console.log("rand2", rand2); | |
var sym = new esri.symbol.PictureMarkerSymbol('assets/images/enemy.png', 30, 30); | |
var enemyMaker = function(x, y) { | |
var e = esri.geometry.geographicToWebMercator(new esri.geometry.Point(x,y)); | |
var g = new esri.Graphic(e, sym); | |
g.id = "enemy"; | |
g.attributes = {type: "simple", health: 2}; | |
map.graphics.add(g); | |
}; | |
var gen = function(opNums) { | |
for (var t=0; t < 5; t++) { | |
var x = op[opNums[0]](location.coords.longitude, t/500); | |
for (var j=0; j < 5; j++) { | |
var y = op[opNums[1]](location.coords.latitude, j/500); | |
enemyMaker(x, y); | |
} | |
} | |
}; | |
gen([0,0]); | |
gen([1,1]); | |
gen([0,1]); | |
gen([1,0]); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment