목표 : 코드 해석
별표와 점이 끝
역시 소스부터 보자
<html>
<head>
<title>Challenge 16</title>
<body bgcolor=black onload=kk(1,1) onkeypress=mv(event.keyCode)>
<font color=silver id=c></font>
<font color=yellow size=100 style=position:relative id=star>*</font>
<script>
document.body.innerHTML+="<font color=yellow id=aa style=position:relative;left:0;top:0>*</font>";
function mv(cd){
kk(star.style.left-50,star.style.top-50);
if(cd==100) star.style.left=parseInt(star.style.left+0,10)+50+"px";
if(cd==97) star.style.left=parseInt(star.style.left+0,10)-50+"px";
if(cd==119) star.style.top=parseInt(star.style.top+0,10)-50+"px";
if(cd==115) star.style.top=parseInt(star.style.top+0,10)+50+"px";
if(cd==124) location.href=String.fromCharCode(cd)+".php"; // do it!
}
function kk(x,y){
rndc=Math.floor(Math.random()*9000000);
document.body.innerHTML+="<font color=#"+rndc+" id=aa style=position:relative;left:"+x+";top:"+y+" onmouseover=this.innerHTML=''>*</font>";
}
</script>
</body>
</html>
PHP
복사
onkeypress 로 키입력을 받고 star를 움직인다 wasd다.
if(cd==100) - "d" CSS 속성의 값을 50픽셀씩 증가시켜 별표를 오른쪽으로 이동합니다
if(cd==97) - "a" CSS 속성 값을 50픽셀씩 줄여서 별표를 왼쪽으로 이동합니다.a
if(cd==119) - "w" CSS 속성 값을 50픽셀씩 줄여서 별표를 위로 이동합니다.w
if(cd==115) - "s" CSS 속성 값을 50픽셀씩 늘려 별표를 아래로 이동합니다.s
PHP
복사
124는 "|” 다.
그냥 |를 누르라고 주석에 돼있다 do it
눌렀더니 그냥 풀렸다