js+svg实现跳跃小游戏代码
代码语言:html
所属分类:游戏
代码描述:js+svg实现跳跃小游戏代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link href="https://fonts.googleapis.com/css2?family=Oi&display=swap" rel="stylesheet"> <style> body { overflow: hidden; font-family: sans-serif; background: slateblue; background-image: linear-gradient(slateblue 25%, rgb(255 255 255 / 0)), url("data:image/svg+xml,%3Csvg width='12' height='16' viewBox='0 0 12 16' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 .99C4 .445 4.444 0 5 0c.552 0 1 .45 1 .99v4.02C6 5.555 5.556 6 5 6c-.552 0-1-.45-1-.99V.99zm6 8c0-.546.444-.99 1-.99.552 0 1 .45 1 .99v4.02c0 .546-.444.99-1 .99-.552 0-1-.45-1-.99V8.99z' fill='navy' fill-opacity='0.1' fill-rule='evenodd'/%3E%3C/svg%3E"); -webkit-animation: rain 40s linear infinite; animation: rain 40s linear infinite; } @-webkit-keyframes rain { from { background-position-y: 0%; } to { background-position-y: 100%; } } @keyframes rain { from { background-position-y: 0%; } to { background-position-y: 100%; } } #stage { display: grid; place-content: end center; min-height: 100vh; transform-origin: bottom center; } #figure { position: relative; width: 100px; aspect-ratio: 1; perspective: 1000px; } #figure .inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; } #figure .back, #figure .front { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border-radius: 100%; -webkit-backface-visibility: hidden; backface-visibility: hidden; } #figure .back { background: hotpink; transform: rotateY(180deg); box-shadow: inset 0 8px 0 0 rgb(0 0 0 / 0.2), inset 0 -2px 0 0 rgb(255 255 255 / 0.8), inset 0 -12px 0 0 rgb(255 255 255 / 0.2); } #figure .back:before, #figure .back:after { content: ""; position: absolute; width: 20px; height: 15px; background: firebrick; border-radius: 999px 999px 0 0; top: 50%; box-shadow: inset 0 2px 0 0 rgb(255 255 255 / 0.8); -webkit-animation: blink 2s ease infinite; animation: blink 2s ease infinite; -webkit-backface-visibility: hidden; backface-visibility: hidden; } #figure .back:before { left: 18%; rotate: -10deg; } #figure .back:after { right: 18%; rotate: 10deg; } #figure .front { background: aquamarine; box-shadow: inset 0 -8px 0 0 rgb(0 0 0 / 0.2), inset 0 12px 0 0 rgb(255 255 255 / 0.2), inset 0 2px 0 0 rgb(255 255 255 / 0.8); } #figure .front:before, #figure .front:after { content: ""; position: absolute; background: teal; width: 12px; height: 20px; border-radius: 12px 12px 8px 8px; top: 35%; box-shadow: 0 2px 0 0 rgb(255 255 255 / 0.8); -webkit-animation: blink 2s ease infinite; animation: blink 2s ease infinite; -webkit-backface-visibility: hidden; backface-visibility: hidden; } @-webkit-keyframes blink { 95% { scale: 1; } 100% { scale: 1 0.1; } } @keyframes blink { 95% { scale: 1; } 100% { scale: 1 0.1; } } #figure .front:before { left: 27%; } #figure .front:after { right: 27%; } #jumps { position: absolute; top: 50%; left: 50%; translate: -50% -50%; font-size: min(50vw, 400px); font-family: "Oi", sans-serif; color: mediumslateblue; text-shadow: 0 -4px 0 rgb(0 0 0 / 0.2); } #catch { position: absolute; width: 100%; height: 50px; botto.........完整代码请登录后点击上方下载按钮下载查看
网友评论0