Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Untitled Document</title>
- </head>
- <body>
- <div style="border:2px solid #0F0; position:absolute; top:1px; left:1px; width:520px; height:400px" >
- <div id="hinh" style="position:absolute; width:20px; height:20px; border-radius:20px; background-color:red"></div>
- <div id="thanhtruot" style="position:absolute; width:100px; height:10px; background-color:blue"></div>
- <input onkeydown="dieukhien(event);" autofocus="autofocus" />
- <input type="text" disabled="disabled" id="diem" value="0" />
- <script>
- var x=100,y=100;
- var dx=1;dy=1;
- var tx=250;ty=300,dtx=10;
- var a=document.getElementById("diem").value;
- function dichuyen()
- {
- x=x+dx;
- y=y+dy;
- if(x>500||x<1)
- dx=-dx;
- if(y<1)
- dy=-dy;
- if(y>380)
- {
- alert("ฤiแปm" + document.getElementById("diem").value + over());
- }
- if(x>tx&&x<tx+100&&y+20==ty)
- {
- dy=-dy;
- document.getElementById("diem").value++;
- }
- hinh.style.top=y+"px";
- hinh.style.left=x+"px";
- thanhtruot.style.top=ty+"px";
- thanhtruot.style.left=tx+"px";
- }
- setInterval("dichuyen()",0);
- function dieukhien(e)
- {
- if(e.keyCode==39)
- tx=tx+dtx;
- else if(e.keyCode==37)
- tx=tx-dtx;
- }
- function over() {
- location.reload();
- }
- </script>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement