gsap小鸟云朵弹跳小游戏效果代码
代码语言:html
所属分类:游戏
代码描述:gsap小鸟云朵弹跳小游戏效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<html lang="en"><head> <meta charset="UTF-8"> <link href="https://fonts.googleapis.com/css2?family=Gamja+Flower&display=swap" rel="stylesheet"> <style> * { padding: 0; margin: 0; } body { background-color: skyblue; width: 100vw; height: 100vh; overflow: hidden; font-family: "Gamja Flower", cursive; transition: background-color 5s; transition-delay: 0.1s; will-change: background-color; } canvas { z-index: 100; transform: translateZ(10px); background-color: rgba(0, 0, 0, 0) !important; } .keepItUp { position: absolute; top: 40%; z-index: -1; opacity: 1; transition: opacity 0.5s; transition-delay: 0.1s; will-change: opacity; font-size: 10vw; text-align: center; width: 50%; margin-left: 25%; } .timer { position: absolute; top: 40%; z-index: -1; opacity: 1; transition: opacity 0.5s; transition-delay: 0.1s; will-change: opacity; font-size: 5vw; text-align: center; top: 5%; right: 5%; } .choose { position: absolute; bottom: 0%; z-index: 101; opacity: 1; transition: opacity 0.5s; transition-delay: 0.1s; will-change: opacity; font-size: 5vw; text-align: center; width: 50%; margin-left: 25%; } .bird1, .bird2, .bird3 { background-color: transparent; width: 100%; transition: all 0.5s; } .bird1:hover, .bird3:hover { transform: rotateZ(360deg); } .bird2:hover { transform: rotateZ(-360deg); } button { background-color: transparent; border: none; width: 5vw; height: 5vw; } .clouds { width: 400%; height: 20%; position: Absolute; top: 0px; z-index: -1; } .clouds > div { position: Absolute; left: 10vw; top: 5vw; width: 10vw; height: 10vw; background-size: contain; background-image: url(//repo.bfw.wiki/bfwrepo/image/606bc9f1d8962.png); } .clouds > div:nth-child(2) { left: 40vw; top: 10vw; } .clouds > div:nth-child(3) { left: 60vw; top: 2vw; } .clouds > div:nth-child(4) { left: 80vw; top: 3vw; } .clouds > div:nth-child(5) { left: 110vw; top: 10vw; } .clouds > div:nth-child(6) { left: 130vw; top: 2vw; } .clouds > div:nth-child(7) { left: 155vw; top: 3vw; } .clouds > div:nth-child(8) { left: 180vw; top: 10vw; } .clouds > div:nth-child(9) { left: 210vw; top: 10vw; } .clouds > div:nth-child(10) { left: 230vw; top: 2vw; } .clouds > div:nth-child(11) { left: 255vw; top: 3vw; } .clouds > div:nth-child(12) { left: 280vw; top: 10vw; } /*following 4 match first 4 for infinite animation loop*/ .clouds > div:nth-child(13) { left: 310vw; top: 5vw; } .clouds > div:nth-child(14) { left: 340vw; top: 10vw; } .clouds > div:nth-child(15) { left: 360vw; top: 2vw; } .clouds > div:nth-child(16) { left: 380vw; top: 3vw; } </style> </head> <body style="background-color: grey;"> <!-- Images from freesvg.org (https://freesvg.org/yellow-bird) --> <div class="clouds"> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> </div> <div class="timer">0 sec.</div> <div class="keepItUp">Bounce it up!</div> <div class="choose"> Choose your Bird <br> <button onclick="startGame(1)"> <img class="bird1" src="//repo.bfw.wiki/bfwrepo/image/6091ef93e0c30.png"> </button> <button onclick="startGame(2)"> <img class="bird2" src="//repo.bfw.wiki/bfwrepo/image/6091ef93e0c30.png"> </button> <button onclick="startGame(3)"> <img class="bird3" src="//repo.bfw.wiki/bfwrepo/image/6091ef93e0c30.png"> </button> </div> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/gsap.3.3.1.js"></script> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/jquery.3.6.0.js"></script> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/matter.js"></script> <script > var tl = gsap.timeline({ repeat: -1 }); tl.to(".clouds", { xPercent: -75, duration: 15, ease: Linear.easeNone }); function startGame(birdNum) { if (birdNum == 1) { fileLink = "//repo.bfw.wiki/bfwrepo/image/6091ef93e0c30.png"; } else if (birdNum == 2) { fileLink = "//repo.bfw.wiki/bfwrepo/image/6091ef93e0c30.png"; } else { fileLink = "//repo.bfw.wiki/bfwrepo/image/6091ef93e0c30.png"; } $(".choose").css("opacity", "0"); setTimeout(function () { $(".choose").css("display", "none"); }, 500); var winW = $(window).width(); va.........完整代码请登录后点击上方下载按钮下载查看
网友评论0