gsap+svg实现小熊气球漂浮击落小游戏代码

代码语言:html

所属分类:游戏

代码描述:gsap+svg实现小熊气球漂浮击落小游戏代码,看看你能击落多少个小熊气球。

代码标签: gsap svg 小熊 气球 漂浮 击落 小游戏 代码

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

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  

  
  
<style>
@import "normalize.css";

* {
  box-sizing: border-box;
}

:root {
  --digit: hsl(0 0% 100% / 0.8);
}

body {
  display: grid;
  min-height: 100vh;
  place-items: center;
  counter-reset: popped 0;
  overflow: hidden;
  background: hsl(210 80% 90%);
  font-family: 'SF Pro Text', 'SF Pro Icons', 'AOS Icons', 'Helvetica Neue',
    Helvetica, Arial, sans-serif, system-ui;
  font-weight: bold;
}

@media(prefers-color-scheme: dark) {
  body {
    background: hsl(210 30% 15%);
  }
}

.pop-counter {
  font-size: 1.25rem;
  font-weight: bold;
  color: var(--digit);
  font-family: sans-serif, system-ui;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.5rem;
}

main [popover]:not(#results, #level0):popover-open {
  counter-increment: popped 1;
}
main [popover]:not(#results) :checked {
  counter-increment: popped 1;
}

.pops:after {
  content: counter(popped);
  font-size: 1.25rem;
  color: transparent;
}
main:after {
  content: counter(popped);
  top: 1rem;
  left: calc(50% + 2.5rem);
  top: anchor(--status top);
  right: anchor(--status center);
  position: fixed;
  font-size: 1.25rem;
  font-weight: bold;
  color: var(--digit);
  font-family: sans-serif, system-ui;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.5rem;
  z-index: 2;
  opacity: var(--playing, 0);
  transition: opacity 0.2s;
}

[role=image] {
  display: inline-block;
  translate: -50% 0;
}

.dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  translate: -50% -50%;
  background: linear-gradient(hsl(0 0% 15%), hsl(0 0% 15%)) padding-box, linear-gradient(hsl(0 0% 35%), hsl(0 0% 0%)) border-box;
  color: hsl(0 0% 100% / 0.8);
  padding: 2rem;
  display: grid;
  place-items: center;
  transition: transform 0.25s;
  transform: translateY(calc(var(--hide, 0) * 100vh));
  border: solid transparent 4px;
  border-radius: 0.5rem;
  width: 70ch;
  max-width: 100%;
}

.dialog-bear {
  width: 100%;
  height: 100%;
}
.intro-bear {
  height: 100%;
  width: clamp(250px, 20vmin + 1rem, 30rem);
}

.dialog--intro {
  display: grid;
  grid-template-columns: auto 1fr;
}

.score:after {
  content: "You popped "counter(popped)" balloons!";
  font-size: 1.5rem;
}

.intro {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 1rem;
}

.dialog button {
  border: 4px solid white;
  background: transparent;
  padding: 1rem 2rem;
  border-radius: 100px;
  color: white;
  font-weight: bold;
  font-size: 1.25rem;
  transition: background 0.2s;
  cursor: pointer;
}

h1 {
  font-size: 4rem;
  color: white;
  line-height: 1;
  margin: 0;
}

.dialog p {
  font-size: 1.25rem;
  margin: 0;
  font-weight: 300;
}

.dialog button:hover {
  background: hsl(0 90% 50%);
}

.dialog--result {
  display: grid;
  gap: 1rem;
  padding: 2rem 4rem;
}

.dialog--result h2 {
  font-size: 3rem;
  margin: 0;
}

#result:popover-open .dialog--result {
  --hide: 0;
  -webkit-animation: pop-up 0.25s both;
          animation: pop-up 0.25s both;
}

@-webkit-keyframes pop-up {
  from {
    transform: translateY(100vh);
  }
}

@keyframes pop-up {
  from {
    transform: translateY(100vh);
  }
}

:root:has(#level0:popover-open) .dialog--intro {
  --hide: 1;
}

[popover] {
  inset: unset;
  position: fixed;
  height: 100vh;
  width: 100vw;
  inset: 0;
  top: 0;
  border: 0;
  padding: 0;
  overflow: hidden;
  background: transparent;
}

.bear {
  --hue: 280;
  position: absolute;
  top: 100%;
  left: calc(var(--x, 0) * 1%);
  width: calc(var(--size, 0) * 1%);
  translate: -50% 0;
  min-width: 48px;
  aspect-ratio: 1;
  transform: rotateY(calc(var(--flip, 0) * 180deg));
  -webkit-animation: float calc(var(--speed) * 1s) calc(var(--delay) * 1s) infinite linear;
          animation: float calc(var(--speed) * 1s) calc(var(--delay) * 1s) infinite line.........完整代码请登录后点击上方下载按钮下载查看

网友评论0