js实现双人飞行棋游戏代码

代码语言:html

所属分类:其他

代码描述:js实现双人飞行棋游戏代码

代码标签: js 双人 飞行棋 游戏 代码

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

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>双人飞行棋</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Microsoft YaHei', sans-serif;
            background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            align-items: center;
            color: #fff;
            overflow-x: hidden;
        }

        h1 {
            margin: 15px 0 5px;
            font-size: 28px;
            text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
            color: #ffd700;
        }

        /* 顶部信息栏 */
        .top-bar {
            display: flex;
            align-items: center;
            gap: 30px;
            margin: 10px 0;
            flex-wrap: wrap;
            justify-content: center;
        }

        .player-info {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 8px 20px;
            border-radius: 30px;
            font-size: 16px;
            font-weight: bold;
            transition: all 0.3s;
        }

        .player-info.red {
            background: rgba(231, 76, 60, 0.3);
            border: 2px solid #e74c3c;
        }

        .player-info.blue {
            background: rgba(52, 152, 219, 0.3);
            border: 2px solid #3498db;
        }

        .player-info.active {
            transform: scale(1.08);
            box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
        }

        .player-info.red.active {
            box-shadow: 0 0 25px rgba(231, 76, 60, 0.6);
        }

        .player-info.blue.active {
            box-shadow: 0 0 25px rgba(52, 152, 219, 0.6);
        }

        .player-dot {
            width: 20px;
            height: 20px;
            border-radius: 50%;
        }

        .player-dot.red { background: #e74c3c; }
        .player-dot.blue { background: #3498db; }

        /* 骰子区域 */
        .dice-area {
            display: flex;
            align-items: center;
            gap: 15px;
            margin: 8px 0;
        }

        .dice {
            width: 70px;
            height: 70px;
            background: #fff;
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 36px;
            font-weight: bold;
            color: #333;
            cursor: pointer;
            user-select: none;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
            transition: transform 0.1s;
            position: relative;
        }

        .dice:hover {
            transform: scale(1.05);
        }

        .dice.rolling {
            animation: diceRoll 0.5s ease-out;
        }

        @keyframes diceRoll {
            0% { transform: rotateZ(0deg) scale(1); }
            25% { transform: rotateZ(90deg) scale(1.1); }
            50% { transform: rotateZ(180deg) scale(1); }
            75% { transform: rotateZ(270deg) scale(1.1); }
            100% { transform: rotateZ(360deg) scale(1); }
        }

        .roll-btn {
            padding: 10px 28px;
            border: none;
            border-radius: 25px;
            font-size: 16px;
            font-weight: bold;
            cursor: pointer;
            transition: all 0.3s;
            color: #fff;
        }

        .roll-btn.red-turn {
            background: linear-gradient(135deg, #e74c3c, #c0392b);
        }

        .roll-btn.blue-turn {
            background: linear-gradient(135deg, #3498db, #2980b9);
        }

        .roll-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
        }

        .roll-btn:disabled {
            opacity: 0.5;
            cursor: not-allowed;
            transform: none;
        }

        /* 消息 */
        .message {
            font-size: 14px;
            min-height: 22px;
            color: #ffd700;
            text-align: center;
            margin: 5px 0;
        }

        /* 棋盘 */
        .board-container {
            position: relative;
            margin: 10px 0 20px;
        }

        canvas {
            border-radius: 12px;
            box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
        }

        /* 规则说明 */
        .rules {
            max-width: 650px.........完整代码请登录后点击上方下载按钮下载查看

网友评论0