Advertisement
giangnhauqe

game

Oct 31st, 2014
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.12 KB | None | 0 0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Untitled Document</title>
  6. </head>
  7.  
  8. <body>
  9.         <div style="border:2px solid #0F0; position:absolute; top:1px; left:1px; width:520px; height:400px" >
  10.         <div id="hinh" style="position:absolute; width:20px; height:20px; border-radius:20px; background-color:red"></div>
  11.     <div id="thanhtruot" style="position:absolute; width:100px; height:10px; background-color:blue"></div>
  12.     <input onkeydown="dieukhien(event);" autofocus="autofocus" />
  13.     <input type="text" disabled="disabled" id="diem" value="0" />
  14.     <script>
  15.                 var x=100,y=100;
  16.                 var dx=1;dy=1;
  17.                 var tx=250;ty=300,dtx=10;
  18.                 var a=document.getElementById("diem").value;
  19.                 function dichuyen()
  20.                 {
  21.                         x=x+dx;
  22.                         y=y+dy;
  23.                        
  24.                         if(x>500||x<1)
  25.                                dx=-dx;
  26.                                
  27.                         if(y<1)
  28.                                dy=-dy;
  29.                         if(y>380)
  30.                         {
  31.                              
  32.                             alert("ฤ‘iแปƒm" + document.getElementById("diem").value + over());
  33.                            
  34.                         }
  35.                         if(x>tx&&x<tx+100&&y+20==ty)
  36.                          {
  37.                            dy=-dy;
  38.                            document.getElementById("diem").value++;    
  39.                           }
  40.                         hinh.style.top=y+"px";
  41.                         hinh.style.left=x+"px";
  42.                         thanhtruot.style.top=ty+"px";
  43.                         thanhtruot.style.left=tx+"px";
  44.                                                        
  45.                 }
  46.                 setInterval("dichuyen()",0);
  47.                 function dieukhien(e)
  48.                 {
  49.                         if(e.keyCode==39)
  50.                                 tx=tx+dtx;
  51.                         else if(e.keyCode==37)
  52.                                 tx=tx-dtx;
  53.                 }
  54.                 function over() {
  55.     location.reload();
  56.            
  57. }
  58.                
  59.         </script>
  60. </div>
  61. </body>
  62. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement