js实现跳跃避障类小游戏代码
代码语言:html
所属分类:游戏
代码描述:js实现跳跃避障类小游戏代码,按住键盘上下左右键跳动。
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> :root { --tile-line-height: 30px; --tile-size: 10px; --clr: gray; --pl-clr: radial-gradient(circle at 75% 50%, white 1px, transparent 2px), radial-gradient(circle at 25% 50%, white 1px, transparent 2px), radial-gradient(circle at 75% 40%, black 3px, transparent 4px), radial-gradient(circle at 25% 40%, black 3px, transparent 4px), white; } html, body { min-width: 100vw; min-height: 100vh; overflow: hidden; margin: 0; display: grid; place-items: center; background: #111; } #game_console { width: 100%; max-width: 1000px; aspect-ratio: 16 / 9; position: relative; background: #200; text-align: center; line-height: var(--tile-line-height); font-size: 0; color: transparent; user-select: none; box-shadow: 0 20px 20px black; } #game_alert { padding: 1rem 2rem; font-size: 16px; font-family: system-ui, serif; color: white; background: rgba(0,0,0,.75); /* box-sizing: border-box; */ border: 1px dashed white; position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); z-index: 99999; border-radius: 50px; transition: .5s; opacity: 0; pointer-events: none; user-select: none; } h2 { margin: 0; margin-bottom: 10px; } .tile { /* outline: 1px dotted dimgray; */ } .ground { background: dimgray; box-shadow: inset 2px 2px 0 2px rgba(0,0,0,.25), inset -2px -2px 0 2px rgba(0,0,0,.5); } .door { box-shadow: none !important; } .cube { background: var(--clr); box-sizing: border-box; border-top: 5px solid rgba(0,0,0,.25); border-right: 5px solid rgba(0,0,0,.65); border-bottom: 5px solid rgba(0,0,0,.65); border-left: 5px solid rgba(0,0,0,.25); } .stripes { background: linear-gradient(to right, transparent 3px, rgba(0,0,0,.25) 2px), var(--clr); background-size: 6px 11px; background-repeat: repeat-x; background-position: 3px 5px; } .lava { background: linear-gradient(to top, orangered, gold 90%, transparent 90%); background-size: 100% 200%; background-position: 0 0; } .key, .finalgoal { box-sizing: border-box; border-top: 5px solid rgba(0,0,0,.25); border-right: 5px solid rgba(0,0,0,.65); border-bottom: 5px solid rgba(0,0,0,.65); border-left: 5px solid rgba(0,0,0,.25); } .highjump { clip-path: polygon(40% 100%, 60% 100%, 100% 0%, 0% 0%); background: linear-gradient(to bottom, aqua 3px, transparent 3px); background-size: 100% 6px; } #player, #player:after { content:''; width: var(--tile-line-height); height: var(--tile-line-height); background: transparent; position: absolute; /* left: calc(var(--tile-line-height)*27); top: calc(var(--tile-line-height)*13); */ z-index: 10000; pointer-events: none; } #player:after { background: var(--p.........完整代码请登录后点击上方下载按钮下载查看
网友评论0