js实现蜗牛跳跃避障类小游戏代码

代码语言:html

所属分类:游戏

代码描述:js实现蜗牛跳跃避障类小游戏代码,单击鼠标蜗牛跳跃避开坑。

代码标签: js 蜗牛 跳跃 避障 游戏

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">





    <style>
        html {
          min-height: 100vh;
          display: grid;
          place-items: center;
          font-family: system-ui;
          font-size: 12px;
          background: #444;  
          color: #aaa;
        }
        
        #game_console {
          width: 600px;
          max-width: 100%;
          aspect-ratio: 1 / 1;
          position: relative;
          background:
            linear-gradient(to bottom, navy, magenta);  
          image-rendering: pixelated;  
          overflow: hidden;
          box-shadow: 0 10px 15px rgba(0,0,0,.5);
        }
        
        #player {
          width: 35px;
          aspect-ratio: 1 / 1;
          background:     url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAZCAMAAADzN3VRAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAABJQTFRFaZUvrnQYAAAAjMY/+7A7AAAAI4gCxgAAAAZ0Uk5T//////8As7+kvwAAAGdJREFUeNrMkt0OwDAERs2n7//KY1j6w653Ek2aEw2FxgmgQVQJtjAjSRiPLyMzm7mS00TCY+Ck8YzSSJzArw3z1k9jZHmNleXfDjNNAVgq6A0KbBjEVKBC94Brhu+O1fISl97cAgwAZ+oIf1jG0V0AAAAASUVORK5CYII=');
          background-size: 100% 100%;
          position: absolute;
          left: 25%;
          top: 48.5%;
          pointer-events: none;
          z-index: 100;
          animation: snail .2s linear infinite;
        }
        @keyframes snail {
          50% {
            width: 36px;
          }
        }
        
        .pl_jump {
          animation: pl_jump 1s linear forwards !important;
        }
        @keyframes pl_jump {
          40% { transform: translateY(-250%) rotate(-180deg); }
          100% { transform: translateY(0%) rotate(-360deg); }
        }
        
        #the_ground {
          width: 200%;
          height: 200%;
          background: 
            linear-gradient(to bottom, green 2px, #630 2px 25px, green 26px);
          position: absolute;
          left: -50%;
          top: calc(50% + 12.5px);
          transform-origin: 37.5% 0%;
          transform: rotate(20deg);
          transition: 3s;
        }
        
        .gap {
          width: 150px;
          height: 100%;
          position: absolute;
          left: 100%;
          top: 0%;
          background:
            linear-gradient(to bottom, navy, magenta);
          animation: gap 2.5s linear forwards;
        }
        @keyframes gap {
          100% { left: -176px; }
        }
        
        .coin {
          position: absolute;
          left: 100%;
          top: -50px;
     .........完整代码请登录后点击上方下载按钮下载查看

网友评论0