<html>
  <head>
	<meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
	<title>WebCat - 点击开始游戏,躲避碰撞!</title>
    <style>
body {
        display: flex;
        justify-content: center;
        align-items: center;
        height: 100vh;
        margin: 0;
      }
      .fgs{
        display: flex;
        justify-content: center;
        align-items: center;
        height: 100vh;
        margin: 0;
        animation: nko 8000ms linear infinite;
        }
      .box {
        width: 300px;
        height: 300px;
        background:url(1692263957083.png);
        background-size:100% 100%;
        border: 8px solid black;
        border-radius: 200px;
        animation: no 8000ms linear infinite;
        position: relative; /* 添加定位属性 */
      }
      .cdm {
        transition: 1000ms;
        position: absolute;
        top: 125px; /* 调整top属性的值 */
        left: -25px;
        //285px;
        //-25px; 
        /* 调整left属性的值 */
        width: 40px;
        height: 40px;
        border-radius: 200px;
        animation: nko 8000ms linear infinite;
      }
      @keyframes nko {
        0% {
          transform: rotate(360deg);
        }
        100% {
          transform: rotate(0deg);
        }
      }
      @keyframes no {
        0% {
          transform: rotate(0deg);
        }
        100% {
          transform: rotate(360deg);
        }
      }
    .cds{
     position: absolute;
        top: 125px; /* 调整top属性的值 */
        left: -25px;
        //285px;
        //-25px; 
        /* 调整left属性的值 */
        width: 40px;
        height: 40px;
        border-radius: 200px;
        transform-origin:175px 50%;
        animation: nko 2000ms linear infinite;
     }
    </style>
  </head>
  <body id="bodh">
	<h1 style="position: absolute; top: 0; left: 50%; transform: translateX(-50%);">点击屏幕开始游戏</h1>
	<div class="box">
      <img id="ddsa" class="cdm" src="NTIwMzA2NTAxNjcxMjI0NjAyNV8xNjQ5NDg3NTAzODI0_5.jpg"/>
<pre><code>    &lt;img class=&quot;cds&quot; src=&quot;3a72f5a9a157fa39485bf32cd17d2ab8.png&quot;/&gt;
  
&lt;/div&gt;
</code></pre>
 <script>
 var i = 1;
 var s = 1;
 function rtgu(){
 var cdmRect = ddsa.getBoundingClientRect();
      var cdsRect = document.querySelector('.cds').getBoundingClientRect();

      // 判断两个元素的位置关系
      if (cdmRect.left < cdsRect.right && cdmRect.right > cdsRect.left && cdmRect.top < cdsRect.bottom && cdmRect.bottom > cdsRect.top) {
        // 弹出弹窗
        alert('GAME OVER!');
      }
 }
 bodh.onclick=function (){
     if(s==1){
       setInterval(rtgu,4);
       s--;
       }
//alert('qd');
 if(i==1){
  ddsa.style.left='285px';
  i=0;
 }else{
  ddsa.style.left='-25px';
  i=1;
 }
 }
 </script>
  </body>
</html>
WebCat - 点击开始游戏,躲避碰撞!

原文地址: https://www.cveoy.top/t/topic/qnjo 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录