js实现一个万圣节幽灵碰撞游戏代码
代码语言:html
所属分类:游戏
代码描述:js实现一个万圣节幽灵碰撞游戏代码,按住鼠标左键不放让幽灵减速防止撞上 按键盘空格键开始或重新开始。
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style> html { background:#003232; font-family: system-ui; --car-rot: rotate(0deg); --en-rot: rotate(0deg); } body:after { content: ''; position: fixed; inset: 0; z-index: 9999; font-family: system-ui; animation: clouds 25s linear infinite; pointer-events: none; filter: blur(3px); } @keyframes clouds { 100% { background-position: 1200px 0; } } #instructions { background: rgba(0,0,0,.25); color: lightgray; padding: 1rem 2rem; max-width: 300px; position: fixed; bottom: 1rem; left: 1rem; border-radius: 5px; z-index: 2000; } #game_box { position: fixed; inset: 0; display: flex; flex-wrap: nowrap; flex-direction: row; justify-content: center; align-content: center; align-items: center; } .tree { position: absolute; width: 5vmin; aspect-ratio: 1/1.25; z-index: 999; } .tree:before { content:''; width: 100%; height: 100%; background: black; clip-path: polygon(10% 0%, 90% 0%, 90% 90%, 100% 90%, 100% 100%, 0% 100%, 0% 90%, 10% 90%); position: absolute; left: 0; top: 0; transform-origin: 50% 100%; transform: skewX(45deg) scaleY(.5) translateX(-20%); border-radius: 50% 50% 0 0 / 25% 25% 0 0; opacity: .25; } .tree:after { content:'RIP'; width: 100%; height: 100%; background: linear-gradient(to right, rgba(0,0,0,.5), transparent 70%), gray; clip-path: polygon(10% 0%, 90% 0%, 90% 90%, 100% 90%, 100% 100%, 0% 100%, 0% 90%, 10% 90%); position: absolute; left: 0; top: 0; border-radius: 50.........完整代码请登录后点击上方下载按钮下载查看
网友评论0