js实现射击生存类游戏代码

代码语言:html

所属分类:游戏

代码描述:js实现射击生存类游戏代码,wsad移动自己,鼠标点击攻击敌人,不能碰到敌人。

代码标签: js 射击 生存 游戏 代码

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

<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Splat Survivors</title>
    <style>
        body { margin: 0; overflow: hidden; background: #222; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }
        canvas { display: block; position: absolute; top: 0; left: 0; }
        #ground-canvas { z-index: 0; }
        #game-canvas { z-index: 1; }
        
        /* UI 层 */
        #ui-layer {
            position: absolute; top: 0; left: 0; width: 100%; height: 100%;
            z-index: 10; pointer-events: none;
            display: flex; flex-direction: column; justify-content: space-between;
        }

        /* 经验条 */
        #xp-container {
            width: 100%; height: 20px; background: rgba(0,0,0,0.5);
        }
        #xp-bar {
            width: 0%; height: 100%; background: linear-gradient(90deg, #00d2ff, #3a7bd5);
            transition: width 0.2s;
        }
        #stats {
            padding: 10px; color: white; font-weight: bold; text-shadow: 2px 2px 0 #000;
            font-size: 1.2rem;
        }

        /* 升级菜单 */
        #upgrade-menu {
            position: absolute; top: 0; left: 0; width: 100%; height: 100%;
            background: rgba(0,0,0,0.8);
            display: none; align-items: center; justify-content: center; flex-direction: column;
            pointer-events: auto; z-index: 20;
        }
        #upgrade-title { color: #FFD700; font-size: 3rem; margin-bottom: 30px; text-shadow: 0 5px 0 #b35600; }
        .card-container { display: flex; gap: 20px; }
        .card {
            background: #fff; width: 200px; height: 250px; border-radius: 15px;
            display: flex; flex-direction: column; align-items: center; justify-content: center;
            cursor: pointer; transition: transform 0.2s; border: 4px solid #333;
            padding: 10px; text-align: center;
        }
        .card:hover { transform: scale(1.05); border-color:.........完整代码请登录后点击上方下载按钮下载查看

网友评论0