[http://probablyinteractive.com/url-hunter URLHunter]를 만들어보자!! == 정진경 == http://joojis.net/urlhunter.php {{{
Hello, PHP On CentOS6! }}} == 박정근 == * The Hunter.html {{{ The Hunter You should kill all the monsters. Your gun point is 'O' and 'a' is Monsters. }}} * Hunter.js {{{ var replash = function(){ setInter = setInterval("URLChange();",100); } var CrtURL = (document.URL.indexOf('#') == -1)? document.URL+'#': document.URL.slice(0,document.URL.indexOf('#')+1); var URLChange = function(){ if(map.peace){ clearInterval(setInter); location.href = CrtURL + "You Killed monsters!!"; alert("The World has peace!"); }else{ map.makeS(); location.href = CrtURL + " |" + map.s.join('') + "|"; } } document.onkeydown = KeyInput; function KeyInput(e){ var code = (window.event)? window.event.keyCode: e.which; if(code == 39) map.H.right(); else if (code == 37) map.H.left(); else if (code == 32) map.kill(); } function Monster(w){ this.where = w; this.alive = true; this.right = function(){this.where = (this.where+1)%50;} this.left = function(){ this.where = (this.where-1<0)? 49: this.where-1; } this.randomMove = function(){ if (this.alive){ var t = (Math.floor(Math.random()*100)%3); if(t==0) this.right(); else if(t==1) this.left(); }else{ this.where = -1; } } } function Hunter(w){ this.where = w; this.right = function(){this.where = (this.where+1)%50;} this.left = function(){ this.where = (this.where-1<0)? 49: this.where-1; } } function Map(){ this.peace = false; this.a1 = new Monster(Math.floor(Math.random()*50)); this.a2 = new Monster(Math.floor(Math.random()*50)); this.a3 = new Monster(Math.floor(Math.random()*50)); this.a4 = new Monster(Math.floor(Math.random()*50)); this.H = new Hunter(3); this.s = new Array(50); this.makeS = function(){ if((this.a1.where == -1)&&(this.a2.where == -1)&&(this.a3.where == -1)&&(this.a4.where == -1)) this.peace = true; this.a1.randomMove(); this.a2.randomMove(); this.a3.randomMove(); this.a4.randomMove(); if (this.a1.alive) this.s[this.a1.where] = 'a'; if (this.a2.alive) this.s[this.a2.where] = 'a'; if (this.a3.alive) this.s[this.a3.where] = 'a'; if (this.a4.alive) this.s[this.a4.where] = 'a'; if((this.H.where==this.a1.where)||(this.H.where==this.a2.where)||(this.H.where==this.a3.where)||(this.H.where==this.a4.where)) this.s[this.H.where] = '@'; else this.s[this.H.where] = 'O'; var i=0; for(i = 0; i<50;i++){ if((i!=this.a1.where)&&(i!=this.a2.where)&&(i!=this.a3.where)&&(i!=this.a4.where)&&(i!=this.H.where)) this.s[i] = '-'; } } this.deada1 = function(){ this.a1.alive = false; } this.deada2 = function(){ this.a2.alive = false; } this.deada3 = function(){ this.a3.alive = false; } this.deada4 = function(){ this.a4.alive = false; } this.kill = function(){ if (this.H.where == this.a1.where) this.deada1(); else if(this.H.where == this.a2.where) this.deada2(); else if(this.H.where == this.a3.where) this.deada3(); else if(this.H.where == this.a4.where) this.deada4(); } this.allkill = function(){ this.deada1(); this.deada2(); this.deada3(); this.deada4(); } } var map = new Map() map.makeS(); }}} == 김수경 == * url-hunter.html {{{ URL Hunter }}} * url-hunter.js {{{ var state = new Array(); var length = 50; var time = 30; var monsters = new Array(); var player; var url; var timer; function init(){ //initialize map for(var i = 0; i < length; i++){ state[i] = 0; } //create monsters for(var i = 0; i < 4; i++){ monsters[i] = new Character((i*20)%length); } //create Player player = new Character(length/2); //getURL url = location.href; //Initialize timer timer = setInterval("next()", 1000); } //Refactoring 필요 function next(){ for(var i = 0; i < ) time--; draw(); } function toString(){ var map = ""; //lenght 고칠것 for(var i = 0; i < length; i++){ switch(state[i]){ case 0: map += "-"; break; case 1: map += "a"; break; case 2: map += "O"; break; case 3: map += "@"; break; } } return map; } function draw(){ location.href= url + "#" + time + "|" + toString() + "|" + time; } function Character(index){ this.index = index; } Character.prototype.move = function(){ if(Math.random() > 0.5){ this.goLeft(); }else{ this.goRight(); } } Character.prototype.goLeft = function(){ this.index = (this.index == 0) ? length - 1 : this.index - 1; } Character.prototype.goRight = function(){ this.index = (this.index + 1) % length; } }}} * url-hunter.css {{{ 아직 없음 }}} == 김광순 == == 정의정 == ---- [JavaScript/2011년스터디]