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: 'Comic Sans MS', cursive, sans-serif;
            overflow: hidden;
            user-select: none;
        }

        #gameContainer {
            width: 100vw;
            height: 100vh;
            background: linear-gradient(180deg, #87CEEB 0%, #98FB98 100%);
            position: relative;
        }

        /* 天空装饰 */
        .cloud {
            position: absolute;
            background: white;
            border-radius: 50px;
            opacity: 0.9;
            animation: floatCloud 20s infinite linear;
        }

        @keyframes floatCloud {
            0% { transform: translateX(-200px); }
            100% { transform: translateX(calc(100vw + 200px)); }
        }

        /* 太阳 */
        #sun {
            position: absolute;
            top: 30px;
            right: 50px;
            width: 80px;
            height: 80px;
            background: radial-gradient(circle, #FFD700, #FFA500);
            border-radius: 50%;
            box-shadow: 0 0 50px #FFD700;
            animation: sunPulse 3s ease-in-out infinite;
        }

        @keyframes sunPulse {
            0%, 100% { transform: scale(1); box-shadow: 0 0 50px #FFD700; }
            50% { transform: scale(1.05); box-shadow: 0 0 70px #FFD700; }
        }

        /* 顶部状态栏 */
        #statusBar {
            position: absolute;
            top: 10px;
            left: 10px;
            background: rgba(255, 255, 255, 0.9);
            padding: 15px 25px;
            border-radius: 20px;
            box-shadow: 0 5px 20px rgba(0,0,0,0.2);
            display: flex;
            gap: 30px;
            z-index: 100;
        }

        .stat {
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 18px;
            font-weight: bold;
        }

        .stat-icon {
            font-size: 24px;
        }

        /* 工具栏 */
        #toolbar {
            position: absolute;
            bottom: 20px;
            left: 50%;
            transform: translateX(-50%);
            background: rgba(139, 90, 43, 0.95);
            padding: 15px 30px;
            border-radius: 30px;
            display: flex;
            gap: 15px;
            box-shadow: 0 5px 30px rgba(0,0,0,0.3);
            border: 4px solid #654321;
            z-index: 100;
        }

        .tool {
            width: 70px;
            height: 70px;
            border-radius: 15px;
            border: 3px solid #654321;
            cursor: pointer;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            font-size: 30px;
            transition: all 0.3s;
            background: linear-gradient(145deg, #DEB887, #D2691E);
            position: relative;
        }

        .tool:hover {
            transform: translateY(-5px) scale(1.1);
            box-shadow: 0 10px 20px rgba(0,0,0,0.3);
        }

        .tool.active {
            background: linear-gradient(145deg, #90EE90, #32CD32);
            transform: scale(1.1);
            box-shadow: 0 0 20px #32CD32;
        }

        .tool-name {
            font-size: 10px;
            color: white;
            margin-top: 2px;
        }

        .tool-cost {
            position: absolute;
            top: -10px;
            right: -10px;
            background: #FFD700;
            color: #333;
            padding: 2px 6px;
            border-radius: 10px;
            font-size: 11px;
            font-weight: bold;
        }

        /* 花园区域 */
        #garden {
            position: absolute;
            bottom: 120px;
            left: 50%;
            transform: translateX(-50%);
            display: grid;
            grid-template-columns: repeat(5, 1fr);
            gap: 20px;
            padding: 30px;
            background: rgba(139, 69, 19, 0.3);
            border-radius: 30px;
        }

        /* 花盆 */
        .pot {
            width: 120px;
            height: 180px;
            position: relative;
            cursor: poi.........完整代码请登录后点击上方下载按钮下载查看

网友评论0