Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

ProjectD/URLHunter: Difference between revisions

From ZeroWiki
imported>lyuha
No edit summary
(Repair batch-0003 pages from live compare)
 
Line 18: Line 18:
  function mapInitialize(){
  function mapInitialize(){
  for (var i=0; i<mapSize; i++) {
  for (var i=0; i<mapSize; i++) {
  map[i] = '-';
  map[i] = '-';
  }
  }
   
   
  i=0;
  i=0;
  map[hunter] = 'O'
  map[hunter] = 'O'
  while (i<15) {
  while (i<15) {
  var temp=Math.floor(Math.random()*50);
  var temp=Math.floor(Math.random()*50);
  if(map[temp] != 'a' && temp != 25){
  if(map[temp] != 'a' && temp != 25){
  map[temp] = 'a';
  map[temp] = 'a';
  i++;
  i++;
  }
  }
Line 45: Line 45:
  case 37: // move left
  case 37: // move left
  if (hunter != 0) {
  if (hunter != 0) {
  if (map[hunter] == 'O') {
  if (map[hunter] == 'O') {
  if (map[hunter-1] == 'a') {
  if (map[hunter-1] == 'a') {
  map[hunter-1] = '@';
  map[hunter-1] = '@';
  map[hunter] = '-';
  map[hunter] = '-';
  hunter--;
  hunter--;
  break;
  break;
  }
  }
  else {
  else {
  map[hunter-1] = 'O';
  map[hunter-1] = 'O';
  map[hunter] = '-';
  map[hunter] = '-';
  hunter--;
  hunter--;
  break;
  break;
Line 60: Line 60:
  }
  }
  else {
  else {
  if (map[hunter-1] == 'a') {
  if (map[hunter-1] == 'a') {
  map[hunter-1] = '@';
  map[hunter-1] = '@';
  map[hunter] = 'a';
  map[hunter] = 'a';
  hunter--;
  hunter--;
  break;
  break;
  }
  }
  else {
  else {
  map[hunter-1] = 'O';
  map[hunter-1] = 'O';
  map[hunter] = 'a';
  map[hunter] = 'a';
  hunter--;
  hunter--;
  break;
  break;
Line 77: Line 77:
  case 39: //move right
  case 39: //move right
  if (hunter != mapSize-1) {
  if (hunter != mapSize-1) {
  if (map[hunter] == 'O') {
  if (map[hunter] == 'O') {
  if (map[hunter+1] == 'a') {
  if (map[hunter+1] == 'a') {
  map[hunter+1] = '@';
  map[hunter+1] = '@';
  map[hunter] = '-';
  map[hunter] = '-';
  hunter++;
  hunter++;
  break;
  break;
  }
  }
  else {
  else {
  map[hunter+1] = 'O';
  map[hunter+1] = 'O';
  map[hunter] = '-';
  map[hunter] = '-';
  hunter++;
  hunter++;
  break;
  break;
Line 92: Line 92:
  }
  }
  else {
  else {
  if (map[hunter+1] == 'a') {
  if (map[hunter+1] == 'a') {
  map[hunter+1] = '@';
  map[hunter+1] = '@';
  map[hunter] = 'a';
  map[hunter] = 'a';
  hunter++;
  hunter++;
  break;
  break;
  }
  }
  else {
  else {
  map[hunter+1] = 'O';
  map[hunter+1] = 'O';
  map[hunter] = 'a';
  map[hunter] = 'a';
  hunter++;
  hunter++;
  break;
  break;
Line 108: Line 108:
  else break;
  else break;
  case 32: //kill
  case 32: //kill
  if (map[hunter] == '@') {
  if (map[hunter] == '@') {
  map[hunter] = 'O';
  map[hunter] = 'O';
  mopNum--;
  mopNum--;
  break;
  break;
Line 149: Line 149:
       function initializeURL () {
       function initializeURL () {
       for(var i = 0; i < lineLength; i++){
       for(var i = 0; i < lineLength; i++){
       URLline[i] = '-';
       URLline[i] = '-';
       }
       }
       URLline[hunterLoca] = 'O';
       URLline[hunterLoca] = 'O';
       allocEnemy();
       allocEnemy();
         printMap();
         printMap();
Line 159: Line 159:
       for(var i = 0; i < enemyNumber; i++){
       for(var i = 0; i < enemyNumber; i++){
         var enemyLoca = Math.floor(Math.random()*lineLength);
         var enemyLoca = Math.floor(Math.random()*lineLength);
         if(enemyLoca == hunterLoca || URLline[enemyLoca] == 'a'){
         if(enemyLoca == hunterLoca || URLline[enemyLoca] == 'a'){
       i--;
       i--;
       continue;
       continue;
         }
         }
           URLline[enemyLoca] = 'a';
           URLline[enemyLoca] = 'a';
       }
       }
       }
       }
Line 179: Line 179:
         for(var i = 0; i < lineLength; i++){
         for(var i = 0; i < lineLength; i++){
           var temp = Math.floor(Math.random()*3) - 1;
           var temp = Math.floor(Math.random()*3) - 1;
           if(URLline[i] == 'a'){
           if(URLline[i] == 'a'){
             if(URLline[i + temp] == '-'){
             if(URLline[i + temp] == '-'){
               URLline[i] = '-';
               URLline[i] = '-';
               URLline[i + temp] = 'a';
               URLline[i + temp] = 'a';
             }
             }
             else if(URLline[i + temp] == 'O'){
             else if(URLline[i + temp] == 'O'){
               URLline[i] = '-';
               URLline[i] = '-';
               URLline[i + temp] = '@';
               URLline[i + temp] = '@';
             }
             }
           }
           }
           else if(URLline[i] == '@'){
           else if(URLline[i] == '@'){
             if(URLline[i + temp] == '-'){
             if(URLline[i + temp] == '-'){
               URLline[i] = 'O';
               URLline[i] = 'O';
               URLline[i + temp] = 'a';
               URLline[i + temp] = 'a';
             }
             }
           }
           }
Line 204: Line 204:
         if(hunterLoca == 0)
         if(hunterLoca == 0)
         break;
         break;
         if(URLline[hunterLoca] == '@'){
         if(URLline[hunterLoca] == '@'){
         URLline[hunterLoca] = 'a';
         URLline[hunterLoca] = 'a';
         if(URLline[hunterLoca - 1] == '-')
         if(URLline[hunterLoca - 1] == '-')
           URLline[hunterLoca - 1] = 'O';
           URLline[hunterLoca - 1] = 'O';
         else if(URLline[hunterLoca - 1] == 'a')
         else if(URLline[hunterLoca - 1] == 'a')
           URLline[hunterLoca - 1] = '@';
           URLline[hunterLoca - 1] = '@';
         }
         }
         else if(URLline[hunterLoca] == 'O'){
         else if(URLline[hunterLoca] == 'O'){
           URLline[hunterLoca] = '-';
           URLline[hunterLoca] = '-';
         if(URLline[hunterLoca - 1] == '-')
         if(URLline[hunterLoca - 1] == '-')
           URLline[hunterLoca - 1] = 'O';
           URLline[hunterLoca - 1] = 'O';
         else if(URLline[hunterLoca - 1] == 'a')
         else if(URLline[hunterLoca - 1] == 'a')
           URLline[hunterLoca - 1] = '@';
           URLline[hunterLoca - 1] = '@';
         }
         }
         hunterLoca--;
         hunterLoca--;
Line 224: Line 224:
         if(hunterLoca == lineLength - 1)
         if(hunterLoca == lineLength - 1)
         break;
         break;
         if(URLline[hunterLoca] == '@'){
         if(URLline[hunterLoca] == '@'){
         URLline[hunterLoca] = 'a';
         URLline[hunterLoca] = 'a';
         if(URLline[hunterLoca + 1] == '-')
         if(URLline[hunterLoca + 1] == '-')
           URLline[hunterLoca + 1] = 'O';
           URLline[hunterLoca + 1] = 'O';
         else if(URLline[hunterLoca + 1] == 'a')
         else if(URLline[hunterLoca + 1] == 'a')
           URLline[hunterLoca + 1] = '@';
           URLline[hunterLoca + 1] = '@';
         }
         }
         else if(URLline[hunterLoca] == 'O'){
         else if(URLline[hunterLoca] == 'O'){
           URLline[hunterLoca] = '-';
           URLline[hunterLoca] = '-';
         if(URLline[hunterLoca + 1] == '-')
         if(URLline[hunterLoca + 1] == '-')
           URLline[hunterLoca + 1] = 'O';
           URLline[hunterLoca + 1] = 'O';
         else if(URLline[hunterLoca + 1] == 'a')
         else if(URLline[hunterLoca + 1] == 'a')
           URLline[hunterLoca + 1] = '@';
           URLline[hunterLoca + 1] = '@';
         }
         }
         hunterLoca++;
         hunterLoca++;
Line 242: Line 242:
   
   
       case 32:  //space
       case 32:  //space
         if(URLline[hunterLoca] == '@'){
         if(URLline[hunterLoca] == '@'){
         URLline[hunterLoca] = 'O';
         URLline[hunterLoca] = 'O';
         enemyNumber--;
         enemyNumber--;
         }
         }
Line 253: Line 253:
       function checkGameEnd() {
       function checkGameEnd() {
       if(enemyNumber == 0)
       if(enemyNumber == 0)
       alert("게임 클리어! [걸린 시간 : " + time + "초]");
       alert("게임 클리어! [걸린 시간 : " + time + "초]");
       }
       }
   
   
Line 288: Line 288:
             for( var i = 0; i < enemy.position.length; i++ ) {
             for( var i = 0; i < enemy.position.length; i++ ) {
                 temp = Math.floor(Math.random()*3)-1;
                 temp = Math.floor(Math.random()*3)-1;
                 if( enemy.position[i] != null && maps[enemy.position[i]+temp] == "-" ) {
                 if( enemy.position[i] != null && maps[enemy.position[i]+temp] == "-" ) {
                     enemy.position[i] += temp;
                     enemy.position[i] += temp;
                 }else{
                 }else{
                     continue;
                     continue;
Line 299: Line 299:
             start_time = new Date();
             start_time = new Date();
             for( var i = 0; i < enemy.position.length; i++ ) {
             for( var i = 0; i < enemy.position.length; i++ ) {
                 enemy.position[i] = null;
                 enemy.position[i] = null;
             }
             }
             while( enemy.position.indexOf(null) != -1 ) {
             while( enemy.position.indexOf(null) != -1 ) {
                 var temp = Math.floor(Math.random()*40);
                 var temp = Math.floor(Math.random()*40);
                 if( temp != 20 && enemy.position.indexOf(temp) == -1 ) { enemy.position[index++] = temp; }
                 if( temp != 20 && enemy.position.indexOf(temp) == -1 ) { enemy.position[index++] = temp; }
             }
             }
             print_map();
             print_map();
Line 309: Line 309:
         function update_map() {
         function update_map() {
             for( var i = 0; i < maps.length; i++ ) {
             for( var i = 0; i < maps.length; i++ ) {
                 maps[i] = "-";
                 maps[i] = "-";
             }
             }
             for( i = 0; i < enemy.position.length; i++ ) {
             for( i = 0; i < enemy.position.length; i++ ) {
                 maps[enemy.position[i]] = "a";
                 maps[enemy.position[i]] = "a";
             }
             }
             if( maps[hunter_position] == "a" ) {
             if( maps[hunter_position] == "a" ) {
                 maps[hunter_position] = "@";
                 maps[hunter_position] = "@";
             }else{
             }else{
                 maps[hunter_position] = "O";
                 maps[hunter_position] = "O";
             }
             }
         }
         }
Line 345: Line 345:
                     break;
                     break;
                 case 32: //Space
                 case 32: //Space
                     if( maps[hunter_position] == "@" ) {
                     if( maps[hunter_position] == "@" ) {
                         var temp = enemy.position.indexOf(hunter_position);
                         var temp = enemy.position.indexOf(hunter_position);
                         enemy.position[temp] = null;
                         enemy.position[temp] = null;
                     }
                     }
                     print_map();
                     print_map();
Line 394: Line 394:
  function make_map(){
  function make_map(){
  for(count=0;count<50;count++)
  for(count=0;count<50;count++)
  map[count] = '-';
  map[count] = '-';
   
   
  make_a();
  make_a();
  map[hunter]='0';                     
  map[hunter]='0';                     
  reshow();
  reshow();
  }
  }
Line 404: Line 404:
  for(count=0;count<10;count++){
  for(count=0;count<10;count++){
  a=Math.floor(Math.random()*50);
  a=Math.floor(Math.random()*50);
  if(map[a]=='-') map[a]='a';
  if(map[a]=='-') map[a]='a';
  else count--;
  else count--;
  }
  }
Line 411: Line 411:
             var temp;
             var temp;
             for(count=0;count<50;count++){
             for(count=0;count<50;count++){
             if(map[count]=='a'){
             if(map[count]=='a'){
  temp=count;
  temp=count;
  temp=temp+(Math.floor(Math.random()*3)-1);
  temp=temp+(Math.floor(Math.random()*3)-1);
  if(temp<0) temp=49+temp;
  if(temp<0) temp=49+temp;
  if(temp>50) temp=temp-49;
  if(temp>50) temp=temp-49;
  if(map[temp]=='-'){
  if(map[temp]=='-'){
  map[temp]='a';
  map[temp]='a';
  map[count]='-';
  map[count]='-';
                         }
                         }
                     }
                     }
Line 427: Line 427:
  case 37://left
  case 37://left
                 if(hunter>0) hunter--;
                 if(hunter>0) hunter--;
                     if(map[hunter]=='a') map[hunter]='@';
                     if(map[hunter]=='a') map[hunter]='@';
                     else map[hunter]='O';
                     else map[hunter]='O';
                          
                          
                     if(map[hunter+1]=='@') map[hunter+1]='a';
                     if(map[hunter+1]=='@') map[hunter+1]='a';
                     else map[hunter+1]='-';
                     else map[hunter+1]='-';
   
   
                     reshow();
                     reshow();
Line 438: Line 438:
  case 39://right
  case 39://right
                     if(hunter<49) hunter++;
                     if(hunter<49) hunter++;
                     if(map[hunter]=='a') map[hunter]='@';
                     if(map[hunter]=='a') map[hunter]='@';
                         else map[hunter]='O';
                         else map[hunter]='O';
                          
                          
                         if(map[hunter-1]=='@') map[hunter-1]='a';
                         if(map[hunter-1]=='@') map[hunter-1]='a';
                         else map[hunter-1]='-';
                         else map[hunter-1]='-';
    
    
                     reshow();
                     reshow();
Line 448: Line 448:
   
   
  case 32://SpaceBar
  case 32://SpaceBar
                     if(map[hunter]=='@') map[hunter]='O';
                     if(map[hunter]=='@') map[hunter]='O';
                     reshow();
                     reshow();
                     break;
                     break;
Line 468: Line 468:
  </html>
  </html>
* a가 워프를 탐;;
* a가 워프를 탐;;

Latest revision as of 00:29, 27 March 2026

상위 문서로: ProjectD

송치완

발퀄주의

<html>
    <head>
        <title>URL Hunter</title>
        <script>
        var mapSize=50;
		var hunter=25;
		var map=new Array(mapSize);
		var mopNum=15;
		var time=0;

		function mapInitialize(){
			for (var i=0; i<mapSize; i++) {
				map[i] = '-';
			}

			i=0;
			map[hunter] = 'O'
			while (i<15) {
				var temp=Math.floor(Math.random()*50);
				if(map[temp] != 'a' && temp != 25){
					map[temp] = 'a';
					i++;
				}
			}
		}	

		function mapDraw(){
			location.href="./URLHunter.html#|||" + map.join() + "|||";
		}

		function timeCheck(){
			setInterval("time+=1", 1000);
		}

		function gamePlay(){

			switch(event.keyCode) {
				case 37: // move left
					if (hunter != 0) {
						if (map[hunter] == 'O') {
							if (map[hunter-1] == 'a') {
								map[hunter-1] = '@';
								map[hunter] = '-';
								hunter--;
								break;
							}
							else {
								map[hunter-1] = 'O';
								map[hunter] = '-';
								hunter--;
								break;
							}
						}
						else {
							if (map[hunter-1] == 'a') {
								map[hunter-1] = '@';
								map[hunter] = 'a';
								hunter--;
								break;
							}
							else {
								map[hunter-1] = 'O';
								map[hunter] = 'a';
								hunter--;
								break;
							}
						}
					}
					else break;
				case 39: //move right
					if (hunter != mapSize-1) {
						if (map[hunter] == 'O') {
							if (map[hunter+1] == 'a') {
								map[hunter+1] = '@';
								map[hunter] = '-';
								hunter++;
								break;
							}
							else {
								map[hunter+1] = 'O';
								map[hunter] = '-';
								hunter++;
								break;
							}
						}
						else {
							if (map[hunter+1] == 'a') {
								map[hunter+1] = '@';
								map[hunter] = 'a';
								hunter++;
								break;
							}
							else {
								map[hunter+1] = 'O';
								map[hunter] = 'a';
								hunter++;
								break;
							}
						}
					}
					else break;
				case 32: //kill
					if (map[hunter] == '@') {
						map[hunter] = 'O';
						mopNum--;
						break;
					}
					else break;
				}
				mapDraw();
			}

			function gameFin(){
				if (mopNum==0) alert("you spent " + time + " seconds");
			}

        </script>
    </head>
    <body onload="mapInitialize(); mapDraw(); timeCheck();" onkeydown="gamePlay(); gameFin();">
    	Move with Arrow Key and press Space Bar to kill
    	<br>tic-tok
    </body>
</html>

버그: 게임이 끝나도 시간이 안 멈춤

최다인

제껀 움직입니다!!

<html>
  <meta charset = "utf-8">
  <head>
    <title>URL Hunter by MeYou</title>
    <script>
      var lineLength = 40;
      var hunterLoca = 20;
      var enemyNumber = 10;
      var URLline = new Array(lineLength);
      var time = 0;

      function initializeURL () {
      	for(var i = 0; i < lineLength; i++){
      		URLline[i] = '-';
      	}
      	URLline[hunterLoca] = 'O';
      	allocEnemy();
        printMap();
      }

      function allocEnemy () {
      	for(var i = 0; i < enemyNumber; i++){
      	  var enemyLoca = Math.floor(Math.random()*lineLength);
      	  if(enemyLoca == hunterLoca || URLline[enemyLoca] == 'a'){
      		i--;
      		continue;
      	  }
          URLline[enemyLoca] = 'a';
      	}
      }

      function checkTime () {
      	setInterval("time++",1000);
        setInterval(function e () {moveEnemy();},333);
      }

      function printMap () {
      	location.href = "./URLHunter.html#|||" + URLline.join() + "|||";
      }

      function moveEnemy () {
        for(var i = 0; i < lineLength; i++){
          var temp = Math.floor(Math.random()*3) - 1;
          if(URLline[i] == 'a'){
            if(URLline[i + temp] == '-'){
              URLline[i] = '-';
              URLline[i + temp] = 'a';
            }
            else if(URLline[i + temp] == 'O'){
              URLline[i] = '-';
              URLline[i + temp] = '@';
            }
          }
          else if(URLline[i] == '@'){
            if(URLline[i + temp] == '-'){
              URLline[i] = 'O';
              URLline[i + temp] = 'a';
            }
          }
        }
        printMap();
      }

      function keyboardInput() {
      	switch(event.keyCode){
      		case 37:  //left
      		  if(hunterLoca == 0)
      		  	break;
      		  if(URLline[hunterLoca] == '@'){
      		  	URLline[hunterLoca] = 'a';
      		  	if(URLline[hunterLoca - 1] == '-')
      		  	  URLline[hunterLoca - 1] = 'O';
      		  	else if(URLline[hunterLoca - 1] == 'a')
      		  	  URLline[hunterLoca - 1] = '@';
      		  }
      		  else if(URLline[hunterLoca] == 'O'){
      		  	  URLline[hunterLoca] = '-';
      		  	if(URLline[hunterLoca - 1] == '-')
      		  	  URLline[hunterLoca - 1] = 'O';
      		  	else if(URLline[hunterLoca - 1] == 'a')
      		  	  URLline[hunterLoca - 1] = '@';
      		  }
      		  hunterLoca--;
      		  break;

      		case 39:  //right
      		  if(hunterLoca == lineLength - 1)
      		  	break;
      		  if(URLline[hunterLoca] == '@'){
      		  	URLline[hunterLoca] = 'a';
      		  	if(URLline[hunterLoca + 1] == '-')
      		  	  URLline[hunterLoca + 1] = 'O';
      		  	else if(URLline[hunterLoca + 1] == 'a')
      		  	  URLline[hunterLoca + 1] = '@';
      		  }
      		  else if(URLline[hunterLoca] == 'O'){
      		  	  URLline[hunterLoca] = '-';
      		  	if(URLline[hunterLoca + 1] == '-')
      		  	  URLline[hunterLoca + 1] = 'O';
      		  	else if(URLline[hunterLoca + 1] == 'a')
      		  	  URLline[hunterLoca + 1] = '@';
      		  }
      		  hunterLoca++;
      		  break;

      		case 32:  //space
      		  if(URLline[hunterLoca] == '@'){
      		  	URLline[hunterLoca] = 'O';
      		  	enemyNumber--;
      		  }
      		  break;
      	}
      	printMap();
      }

      function checkGameEnd() {
      	if(enemyNumber == 0)
      		alert("게임 클리어! [걸린 시간 : " + time + "초]");
      }


    </script>
  </head>
  <body onload = "initializeURL(); checkTime();" onkeydown = "keyboardInput();" onkeyup = "checkGameEnd();">
    URL Hunter
  </body>
</html>

근데 치완선배랑 똑같은 버그 ㅋㅋㅋㅋㅋㅋㅋ시간아 멈춰라.....

  • clearInterval(timecheck); , var timecheck = function (){} 이런 구문이면 가능했던걸로 기억하는데 실험해보시죠! - 이원준
    • 오오 이거 뭐야. 귀찮다. 안할래. - 최다인

이원준

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <script>
        var maps = new Array(40),
            enemy = {
                remind : 10
            },
            hunter_position = 20,
            start_time = undefined,
            current_time = undefined;

        enemy.position = new Array(enemy.remind);

        enemy.move = function() {
            var temp;
            for( var i = 0; i < enemy.position.length; i++ ) {
                temp = Math.floor(Math.random()*3)-1;
                if( enemy.position[i] != null && maps[enemy.position[i]+temp] == "-" ) {
                    enemy.position[i] += temp;
                }else{
                    continue;
                }
            }
        }
        function init_map() {
            var index = 0;
            start_time = new Date();
            for( var i = 0; i < enemy.position.length; i++ ) {
                enemy.position[i] = null;
            }
            while( enemy.position.indexOf(null) != -1 ) {
                var temp = Math.floor(Math.random()*40);
                if( temp != 20 && enemy.position.indexOf(temp) == -1 ) { enemy.position[index++] = temp; }
            }
            print_map();
        }
        function update_map() {
            for( var i = 0; i < maps.length; i++ ) {
                maps[i] = "-";
            }
            for( i = 0; i < enemy.position.length; i++ ) {
                maps[enemy.position[i]] = "a";
            }
            if( maps[hunter_position] == "a" ) {
                maps[hunter_position] = "@";
            }else{
                maps[hunter_position] = "O";
            }
        }
        function print_map() {
            current_time = new Date();
            update_map();
            location.href = "./url_hunter.html#||"+maps.join("")+"||";
            check_end();
        }
        function move_hunter(direction) {
            if( direction == "left" && hunter_position > 0 ){
                hunter_position--;
            }
            if( direction == "right" && hunter_position < 39 ){
                hunter_position++;
            }
        }
        function key_input() {
            switch(event.keyCode) {
                case 37: //Left
                    move_hunter("left");
                    print_map();
                    break;
                case 39: //Right
                    move_hunter("right");
                    print_map();
                    break;
                case 32: //Space
                    if( maps[hunter_position] == "@" ) {
                        var temp = enemy.position.indexOf(hunter_position);
                        enemy.position[temp] = null;
                    }
                    print_map();
                    break;
                default:
                    break;
            }
        }
        function check_end() {
            if( enemy.position.every(function(element, index, array){ return (element == null); }) ) {
                location.href = "./url_hunter.html#||"+maps.join("")+"||";
                clearInterval(timer1);
                clearInterval(timer2);
                clearInterval(timer3);
                return true;
            }
        }
        function print_time() {
            document.getElementById("time").innerHTML = ((current_time.getTime() - start_time.getTime())/1000);
        }
        var timer1 = setInterval(enemy.move, 500);
        var timer2 = setInterval(print_map, 500)
        var timer3 = setInterval(print_time, 100);
    </script>
</head>
<body onload="init_map();" onkeydown="key_input();">
    <!-- <input type="button" value="pause" onclick="pause_game();"/> -->
    <!-- <input type="button" value="continue" onclick="continue_game();"/> -->
    <input type="button" value="restart" onclick="location.href='./url_hunter.html'">
    <p>Time : <span id="time">0</span> Sec</p>
</body>
</html>
  • 여러 구문들을 넣어보려고 했으나 실패했습니다. ㅠ

김용준

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8"/>
	<script>
	var map=new Array(50);
	var hunter=25;
	var count;

		function make_map(){
			for(count=0;count<50;count++)
			map[count] = '-';

			make_a();
			map[hunter]='0';                    
			reshow();
		}

		function make_a(){
			for(count=0;count<10;count++){
				a=Math.floor(Math.random()*50);
					if(map[a]=='-') map[a]='a';
					else count--;
			}
		}
		function move_a(){
            var temp;
            	for(count=0;count<50;count++){
            		if(map[count]=='a'){
						temp=count;
						temp=temp+(Math.floor(Math.random()*3)-1);
						if(temp<0) temp=49+temp;
						if(temp>50) temp=temp-49;
							if(map[temp]=='-'){
								map[temp]='a';
								map[count]='-';
                        	}
                    }
                }
		}
		function keyboard(){		
			switch(event.keyCode){
				case 37://left
             	   if(hunter>0) hunter--;
                    	if(map[hunter]=='a') map[hunter]='@';
                    	else map[hunter]='O';
                        
                 	   if(map[hunter+1]=='@') map[hunter+1]='a';
                 	   else map[hunter+1]='-';

                    reshow();
                    break;

				case 39://right
                   	if(hunter<49) hunter++;
                   		if(map[hunter]=='a') map[hunter]='@';
                       	else map[hunter]='O';
                        
                        if(map[hunter-1]=='@') map[hunter-1]='a';
                        else map[hunter-1]='-';
   	
                    reshow();
                    break;

					case 32://SpaceBar
                    if(map[hunter]=='@') map[hunter]='O';
                    reshow();
                    break;
                }
            }



		function reshow(){
			location.href="./URL_Hunter.html#|"+map.join()+"|";
			move_a();
		}


	</script>
</head>
<body onload="make_map();" onkeydown="keyboard();">
</body>
</html>
  • a가 워프를 탐;;