<!doctype html> <html> <head> <script> window.onerror=alert </script> <style> *{ overflow:hidden; margin:0px; padding:0px; } #controlPanel{ position:relative; top:-40px; } button{ opacity:60%; color:#000; } .controls{ position: relative; width: 16%; padding-top: 16%; } .controls_content{ position: absolute; top: 0; left: 0; bottom: 0; right: 0; } html,body{ background:#000; height:100%; } </style> <script> function onload_(){ window.userRayCountSet=false window.userRayCount=200 function not(a){ if(a){return false} return true }function or(a,b){ if(b){return true} if(a){return true} return false } window.canvas=document.getElementById('canvas') window.ctx=canvas.getContext('2d') //GLOBAL GRAPHON PERMANENT window.FOV=Math.PI/2 window.halfFOV=FOV/2 //GLOBAL GRAPHON AUTOMATIC function resize_(doNot){ window.width=window.innerWidth window.height=window.innerHeight window.height=Math.max(150,height) window.wh=width/height canvas.height=height canvas.width=width controlPanel=document.getElementById('controlPanel') controlPanel.style.top="-"+controlPanel.getBoundingClientRect().height+"px" window.rayCount=userRayCount//Math.floor(userRayCount/(raySkip+1)) window.stepAngle=FOV/rayCount window.lineWidth=width/userRayCount+1 } function resize_draw(){resize_();draw()} resize_(false) window.onresize=resize_draw //KARTA window.userX=2 window.userY=2 window.userAngle=0 window.startAngle=userAngle-halfFOV window.curAngle=startAngle window.curMap=0 //GLOBAL GRAPHON SETTABLE userRayCount=200 window.maxDepth=10 window.stepDepth=0.02 window.lineWidth=width/userRayCount+1 window.userStep=0.2 //KARTA GRAPHON //window.raySkip=0 window.rayCount=userRayCount window.stepAngle=FOV/rayCount window.sepWidth=0.04 //MAP INDECES window.__color__ =0 window.__interactive__ =1 window.__text__ =2 window.__collision__ =3 window.__portal_x__ =4 window.__portal_y__ =5 window.__portal_angle__=6 window.__floor__ =7 window.__sky__ =8 window.__second_flr__ =9 window.__mirror__ =10 window.__filter__ =11 maps=[ [ [1,1,2,3,4,1], [16,0,0,0,0,5], [15,0,0,0,0,6], [14,0,0,0,0,7], [13,0,0,0,0,8], [13,12,11,10,9,9] ] ] graphics_h_colors=[ '#000000', '#000080', '#008000', '#008080', '#800000', '#800080', '#808000', '#c0c0c0', '#808080', '#8080ff', '#80ff80', '#80ffff', '#ff8080', '#FF80FF', '#ffff00', '#ffffff', '#96FAC8', '#323232' ] function draw(){ curAngle=startAngle for(i=0;i<rayCount;i+=1){ curAngle+=stepAngle for(depth=0;depth<maxDepth;depth+=stepDepth){ Dx=Math.cos(curAngle)*depth Dy=Math.sin(curAngle)*depth Ux=Dx+userX Uy=Dy+userY Fx=Math.floor(Ux) Fy=Math.floor(Uy) try{cellVal=maps[curMap][Fy][Fx]} catch(e){cellVal=0;alert(e)} Lx=Math.min(Ux-Fx,1-Ux+Fx) Ly=Math.min(Uy-Fy,1-Uy+Fy) if(cellVal>0){ lineX=i*width/rayCount if(or(Lx>sepWidth,Ly>sepWidth)){ len=width/(2*Math.tan(halfFOV)*depth)/Math.cos(Math.abs(curAngle-userAngle)) ctx.fillStyle=graphics_h_colors[cellVal-1] ctx.fillRect(lineX,(height-len)/2,lineWidth,len) } break } } } }function drawRight(){ userAngle+=0.35 startAngle+=0.35 ctx.clearRect(0,0,width,height) draw() }function drawRight_key(){ userAngle+=0.05 startAngle+=0.05 ctx.clearRect(0,0,width,height) draw() }function drawForward(){ Dy=Math.sin(userAngle)*1 Uy=Dy+userY Fy=Math.floor(Uy) cellVal=maps[curMap][Fy][Math.floor(userX)] if(cellVal==0){ userY=Uy } Dx=Math.cos(userAngle)*1 Ux=Dx+userX Fx=Math.floor(Ux) cellVal=maps[curMap][Math.floor(userY)][Fx] if(cellVal==0){ userX=Ux } ctx.clearRect(0,0,width,height) draw() }function drawForward_key(){ Dy=Math.sin(userAngle)*userStep Uy=Dy+userY Fy=Math.floor(Uy) cellVal=maps[curMap][Fy][Math.floor(userX)] if(cellVal==0){ userY=Uy } Dx=Math.cos(userAngle)*userStep Ux=Dx+userX Fx=Math.floor(Ux) cellVal=maps[curMap][Math.floor(userY)][Fx] if(cellVal==0){ userX=Ux } ctx.clearRect(0,0,width,height) draw() }function drawLeft(){ userAngle-=0.35 startAngle-=0.35 ctx.clearRect(0,0,width,height) draw() }function drawLeft_key(){ userAngle-=0.05 startAngle-=0.05 ctx.clearRect(0,0,width,height) draw() }function drawBackward(){ Dy=Math.sin(userAngle)*(-1) Uy=Dy+userY Fy=Math.floor(Uy) cellVal=maps[curMap][Fy][Math.floor(userX)] if(cellVal==0){ userY=Uy } Dx=Math.cos(userAngle)*(-1) Ux=Dx+userX Fx=Math.floor(Ux) cellVal=maps[curMap][Math.floor(userY)][Fx] if(cellVal==0){ userX=Ux } ctx.clearRect(0,0,width,height) draw() }function drawBackward_key(){ Dy=Math.sin(userAngle)*(-userStep) Uy=Dy+userY Fy=Math.floor(Uy) cellVal=maps[curMap][Fy][Math.floor(userX)] if(cellVal==0){ userY=Uy } Dx=Math.cos(userAngle)*(-userStep) Ux=Dx+userX Fx=Math.floor(Ux) cellVal=maps[curMap][Math.floor(userY)][Fx] if(cellVal==0){ userX=Ux } ctx.clearRect(0,0,width,height) draw() } //alert('Successfully') draw() function key_down(event){ if(event.key=='ArrowLeft'){drawLeft_key()} if(event.key=='ArrowRight'){drawRight_key()} if(event.key=='ArrowUp'){drawForward_key()} if(event.key=='ArrowDown'){drawBackward_key()} } window.onkeydown=key_down window.drawBackward=drawBackward window.drawForward=drawForward window.drawLeft=drawLeft window.drawRight=drawRight window.draw=draw window.controls=[0,0,0] //rotate,moveVA,move<> window.pressuresDown=[0,0,0,0,0,0] window.pressuresUp=[0,0,0,0,0,0] window.pressuresTime=[0,0,0,0,0,0] window.buttonClickDelay=20 //rl,ml,mf,mb,mr,rr function controlMove(){ if(controls[0]===1){ drawRight_key() } if(controls[0]===-1){ drawLeft_key() } if(controls[1]===1){ drawForward_key() } if(controls[1]===-1){ drawBackward_key() } if(controls[2]===1){ } if(controls[2]===-1){ } setTimeout(controlMove,30) } controlMove() function mouseTouchControl(){} function pass(){} window.pass=pass window.mouseTouchControl=mouseTouchControl function blockClicks(e){ Rslt='' Ks=Object.keys(e) for(k=0;k<Ks.length;k+=1){ Rslt+='\n'+Ks[k]+eval('e.'+Ks[k]) } alert(Rslt) if(true){ button_list=['R','L','F','B'] for(btn=0;btn<button_list.length;btn+=1){ document.getElementById(button_list[btn]).onclick=pass } } document.onmousemove=mouseTouchControl document.ontouchmove=mouseTouchControl } //document.onmousemove=blockClicks //document.ontouchmove=blockClicks //document.onmouseover=blockClicks window.blockClicks=blockClicks window.resize_=resize_ } </script><script> function onload_2(){ gameBlock =document.getElementById('gameBlock') menuBlock =document.getElementById('menuBlock') shopBlock =document.getElementById('shopBlock') creatorBlock =document.getElementById('creatorBlock') levelSelectBlock =document.getElementById('levelSelectBlock') settingsBlock =document.getElementById('settingsBlock') blockList=[gameBlock,menuBlock,shopBlock,creatorBlock,levelSelectBlock,settingsBlock] blockHistory=[1] function startGame(){ for(bl=0;bl<blockList.length;bl+=1){ blockList[bl].style.display='None' } gameBlock.style.display='block' resize_() draw() }function menu(){ for(bl=0;bl<blockList.length;bl+=1){ blockList[bl].style.display='None' } menuBlock.style.display='block' } window.startGame=startGame window.menu =menu menu() } </script><script> function onload_all(){ onload_() onload_2() } window.onload=onload_all </script> </head> <body oncontextmenu='return false;'> <div id='gameBlock'> <canvas style='background:#000000;' id='canvas'> NA </canvas> <button class='controls' style='position:fixed;top:20px;left:20px;' onclick='menu()'> <span class='controls_content'>MENU</span> </button> <center id='controlPanel'> <button class='controls' onclick='if(event.timeStamp-pressuresDown[0]<buttonClickDelay){drawLeft()}' onmousedown='controls[0]=-1;pressuresDown[0]=event.timeStamp' ontouchstart='controls[0]=-1;pressuresDown[0]=event.timeStamp' onmouseup='controls[0]=0;pressuresUp[0]=event.timeStamp;pressuresTime[0]=pressuresUp[0]-pressuresDown[0]' ontouchend='controls[0]=0;pressuresUp[0]=event.timeStamp;pressuresTime[0]=pressuresUp[0]-pressuresDown[0]' id='L'> <span class='controls_content'>L</span> </button> <button class='controls' onclick='if(event.timeStamp-pressuresDown[2]<buttonClickDelay){drawForward()}' onmousedown='controls[1]=1;pressuresDown[2]=event.timeStamp' ontouchstart='controls[1]=1;pressuresDown[2]=event.timeStamp' onmouseup='controls[1]=0;pressuresUp[2]=event.timeStamp;pressuresTime[2]=pressuresUp[2]-pressuresDown[2]' ontouchend='controls[1]=0;pressuresUp[2]=event.timeStamp;pressuresTime[2]=pressuresUp[2]-pressuresDown[2]' id='F'> <span class='controls_content'>F</span> </button> <button class='controls' onclick='if(event.timeStamp-pressuresDown[-3]<buttonClickDelay){drawBackward()}' onmousedown='controls[1]=-1;pressuresDown[-3]=event.timeStamp' ontouchstart='controls[1]=-1;pressuresDown[-3]=event.timeStamp' onmouseup='controls[1]=0;pressuresUp[-3]=event.timeStamp;pressuresTime[-3]=pressuresUp[-3]-pressuresDown[-3]' ontouchend='controls[1]=0;pressuresUp[-3]=event.timeStamp;pressuresTime[-3]=pressuresUp[-3]-pressuresDown[-3]' id='B'> <span class='controls_content'>B</span> </button> <button class='controls' onclick='if(event.timeStamp-pressuresDown[-1]<buttonClickDelay){drawRight()}' onmousedown='controls[0]=1;pressuresDown[-1]=event.timeStamp' ontouchstart='controls[0]=1;pressuresDown[-1]=event.timeStamp' onmouseup='controls[0]=0;pressuresUp[-1]=event.timeStamp;pressuresTime[-1]=pressuresUp[-1]-pressuresDown[-1]' ontouchend='controls[0]=0;pressuresUp[-1]=event.timeStamp;pressuresTime[-1]=pressuresUp[-1]-pressuresDown[-1]' id='R'> <span class='controls_content'>R</span> </button><br> <button onclick='alert(eval(prompt()))'> <span>eval</span> </button> </center> </div> <div id='menuBlock' style='width:100%;height:100%;'> <button onmousemove='"blockClicks(event)"' onclick='startGame()' style='position:fixed;width:40%;height:26%;top:37%;margin-left:30%;'>PLAY</button> </div> <div id='shopBlock' style='width:100%;height:100%;'> </div> <div id='creatorBlock' style='width:100%;height:100%;'> </div> <div id='levelSelectBlock' style='width:100%;height:100%;'> </div> <div id='settingsBlock' style='width:100%;height:100%;'> </div> </body> </html>
Отправить