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>chi3236
No edit summary
imported>chi3236
No edit summary
Line 1: Line 1:
[[ProjectD]]
== 송치완 ==
== 송치완 ==



Revision as of 08:25, 5 April 2014

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>