[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 Others are Monsters. }}} * URLHunterV1.js {{{ MapLength = 50; 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 caught \'" + map.r.join('') + "\'"; alert("Press F5 to play again"); }else{ timer.templus(); map.makeS(); location.href = CrtURL + " "+timer.t +"|" + map.s.join('') + "|"+timer.t + " You caught \'" + map.r.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 Timer(g){ this.t = g; this.temp = 0; this.templus = function(){ this.temp++; if(this.temp%10 == 0) this.t--; if(this.t <= 0) map.peace = true; } } var timer = new Timer(30); function Creature(){ this.right = function(){ this.where = (this.where+1)%MapLength; } this.left = function(){ this.where = (this.where-1<0)? (MapLength-1): this.where-1; } } function Monster(w){ this.where = w; this.alive = true; 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; } Monster.prototype = new Creature(); Hunter.prototype = new Creature(); function Map(){ this.peace = false; this.a1 = new Monster(Math.floor(Math.random()*MapLength)); this.a2 = new Monster(Math.floor(Math.random()*MapLength)); this.a3 = new Monster(Math.floor(Math.random()*MapLength)); this.a4 = new Monster(Math.floor(Math.random()*MapLength)); this.a5 = new Monster(Math.floor(Math.random()*MapLength)); this.H = new Hunter(Math.floor(Math.random()*MapLength)); this.r = new Array(5); this.s = new Array(MapLength); this.makeS = function(){ if((this.a1.where == -1)&&(this.a2.where == -1)&&(this.a3.where == -1)&&(this.a4.where == -1)&&(this.a5.where == -1)) this.peace = true; this.a1.randomMove(); this.a2.randomMove(); this.a3.randomMove(); this.a4.randomMove(); this.a5.randomMove(); if (this.a1.alive) this.s[this.a1.where] = 'l'; if (this.a2.alive) this.s[this.a2.where] = 'i'; if (this.a3.alive) this.s[this.a3.where] = 'n'; if (this.a4.alive) this.s[this.a4.where] = 'u'; if (this.a5.alive) this.s[this.a5.where] = 's'; if(this.a1.alive) this.r[0] = '_'; else this.r[0] = 'l'; if(this.a2.alive) this.r[1] = '_'; else this.r[1] = 'i'; if(this.a3.alive) this.r[2] = '_'; else this.r[2] = 'n'; if(this.a4.alive) this.r[3] = '_'; else this.r[3] = 'u'; if(this.a5.alive) this.r[4] = '_'; else this.r[4] = 's'; if(this.H.where==this.a1.where) this.s[this.H.where] = 'ⓛ'; else if(this.H.where==this.a2.where) this.s[this.H.where] = 'ⓘ'; else if(this.H.where==this.a3.where) this.s[this.H.where] = 'ⓝ'; else if(this.H.where==this.a4.where) this.s[this.H.where] = 'ⓤ'; else if(this.H.where==this.a5.where) this.s[this.H.where] = 'ⓢ'; else this.s[this.H.where] = 'O'; var i=0; for(i = 0; i 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년스터디]