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 {
            background: linear-gradient(180deg, #87CEEB 0%, #98D8C8 60%, #90EE90 100%);
            overflow: hidden;
            font-family: 'Arial Rounded MT Bold', Arial, sans-serif;
            user-select: none;
        }
        
        #gameContainer {
            width: 100vw;
            height: 100vh;
            position: relative;
        }
        
        canvas {
            display: block;
            width: 100%;
            height: 100%;
        }
        
        #ui {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            pointer-events: none;
        }
        
        #scoreBoard {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 15px 25px;
            background: rgba(255,255,255,0.25);
            backdrop-filter: blur(10px);
            border-bottom: 3px solid rgba(255,255,255,0.5);
        }
        
        .score-item {
            text-align: center;
            color: #2d5a1b;
            text-shadow: 2px 2px 0px rgba(255,255,255,0.8);
        }
        
        .score-label {
            font-size: 12px;
            font-weight: bold;
            text-transform: uppercase;
            letter-spacing: 1px;
        }
        
        .score-value {
            font-size: 28px;
            font-weight: bold;
            color: #ff6b35;
            text-shadow: 3px 3px 0px rgba(0,0,0,0.2);
        }
        
        #healthBar {
            display: flex;
            align-items: center;
            gap: 8px;
        }
        
        .heart {
            font-size: 24px;
            transition: transform 0.3s;
        }
        
        .heart.lost {
            filter: grayscale(1);
            opacity: 0.4;
        }
        
        #startScreen, #gameOverScreen, #levelUpScreen {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            background: rgba(0,0,0,0.4);
            backdrop-filter: blur(8px);
            z-index: 100;
        }
        
        .screen-card {
            background: linear-gradient(135deg, #fff9e6, #fff);
            border-radius: 30px;
            padding: 50px 60px;
            text-align: center;
            box-shadow: 0 20px 60px rgba(0,0,0,0.3),
                        inset 0 2px 0 rgba(255,255,255,0.8);
            border: 4px solid #ffd700;
            max-width: 500px;
            width: 90%;
            animation: cardBounce 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
        }
        
        @keyframes cardBounce {
            from { transform: scale(0.5); opacity: 0; }
            to { transform: scale(1); opacity: 1; }
        }
        
        .screen-title {
            font-size: 52px;
            margin-bottom: 10px;
            animation: titleFloat 2s ease-in-out infinite;
        }
        
        @keyframes titleFloat {
            0%, 100% { transform: translateY(0); }
            50% { transform: translateY(-10px); }
        }
        
        .screen-subtitle {
            font-size: 22px;
            color: #ff6b35;
            font-weight: bold;
            margin-bottom: 20px;
            text-shadow: 2px 2px 0 rgba(0,0,0,0.1);
        }
        
        .screen-desc {
            font-size: 14px;
            color: #666;
            margin-bottom: 30px;
            line-height: 1.8;
        }
        
        .btn {
            background: linear-gradient(135deg, #ff6b35, #ff4500);
            color: white;
            border: none;
            padding: 18px 50px;
            font-size: 22px;
            font-weight: bold;
            border-radius: 50px;
            cursor: pointer;
            box-shadow: 0 8px 0 #cc3300,
                        0 10px 20px rgba(255,107,53,0.4);
            transition: all 0.1s;
            pointer-events: all;
            font-family: inherit;
            letter-spacing: 1px;
        }
        
        .btn:hover {
            background: linear-gradient(135deg, #ff7f50, #ff5500);
            transform: translateY(-3px);
            box-shadow: 0 11px 0 #cc3300, 0 13px 25px rgba(255,107,53,0.4);
        }
        
        .btn:active {
            transform: translateY(5px);
            box-shadow: 0 3px 0 #cc3300, 0 5px 10px rgba(255,107,53,0.4);
        }
        
        .btn-secondary {
            background: linear-gradient(135deg, #4CAF50, #388E3C);
            box-shadow: 0 8px 0 #2E7D32, 0 10px 20px rgba(76,175,80,0.4);
            margin-top: 15px;
        }
        
        .btn-secondary:hover {
            box-shadow: 0 11px 0 #2E7D32, 0 13px 25px rgba(76,175,80,0.4);
        }
        
        .btn-secondary:active {
            box-sh.........完整代码请登录后点击上方下载按钮下载查看

网友评论0