Download index.html from div988/train: direct link, hf CLI and curl.
- Browser
- Download file 41.1 kB
-
https://huggingface.co/spaces/div988/train/resolve/main/index.html
- Command line
-
hf download hf://spaces/div988/train/index.html
-
curl -L -o index.html https://huggingface.co/spaces/div988/train/resolve/main/index.html
41.1 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Indian Railways Simulator</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> | |
| <style> | |
| @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap'); | |
| body { | |
| font-family: 'Poppins', sans-serif; | |
| background-color: #111827; | |
| color: white; | |
| overflow: hidden; | |
| } | |
| .train-body { | |
| background: linear-gradient(90deg, #d10a11 60%, white 60%); | |
| border-radius: 8px; | |
| } | |
| .coach-body { | |
| background: linear-gradient(90deg, #003580 60%, white 60%); | |
| border-radius: 8px; | |
| } | |
| .platform-tiles { | |
| background: repeating-linear-gradient( | |
| 90deg, | |
| #d1d5db, | |
| #d1d5db 20px, | |
| #9ca3af 20px, | |
| #9ca3af 40px | |
| ); | |
| } | |
| .signal-green { | |
| box-shadow: 0 0 20px 5px rgba(74, 222, 128, 0.7); | |
| } | |
| .signal-yellow { | |
| box-shadow: 0 0 20px 5px rgba(234, 179, 8, 0.7); | |
| } | |
| .signal-red { | |
| box-shadow: 0 0 20px 5px rgba(239, 68, 68, 0.7); | |
| } | |
| .fog-effect { | |
| position: absolute; | |
| width: 100%; | |
| height: 100%; | |
| background: rgba(255, 255, 255, 0.2); | |
| backdrop-filter: blur(5px); | |
| pointer-events: none; | |
| } | |
| .rain-effect { | |
| position: absolute; | |
| width: 100%; | |
| height: 100%; | |
| background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200" viewBox="0 0 200 200"><line x1="0" y1="0" x2="200" y2="200" stroke="rgba(255,255,255,0.2)" stroke-width="1"/></svg>'); | |
| animation: rain 0.5s linear infinite; | |
| pointer-events: none; | |
| } | |
| @keyframes rain { | |
| 0% { background-position: 0 0; } | |
| 100% { background-position: 200px 200px; } | |
| } | |
| .gauge-fill { | |
| transition: height 0.3s ease; | |
| } | |
| .cabin-panel { | |
| background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%); | |
| border-radius: 8px; | |
| box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3); | |
| } | |
| .button-glow:active { | |
| box-shadow: 0 0 15px 5px rgba(59, 130, 246, 0.5); | |
| } | |
| #gameCanvas { | |
| border-radius: 8px; | |
| box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3); | |
| } | |
| .passenger { | |
| animation: passenger-walk 4s infinite linear; | |
| } | |
| @keyframes passenger-walk { | |
| 0% { transform: translateX(-50px); opacity: 0; } | |
| 10% { opacity: 1; } | |
| 90% { opacity: 1; } | |
| 100% { transform: translateX(50px); opacity: 0; } | |
| } | |
| .blinking { | |
| animation: blink 1s infinite; | |
| } | |
| @keyframes blink { | |
| 0%, 100% { opacity: 1; } | |
| 50% { opacity: 0.5; } | |
| } | |
| </style> | |
| </head> | |
| <body class="h-screen flex flex-col"> | |
| <!-- Header --> | |
| <header class="bg-red-800 py-2 px-4 flex justify-between items-center border-b-2 border-yellow-500"> | |
| <div class="flex items-center"> | |
| <img src="https://upload.wikimedia.org/wikipedia/en/thumb/3/37/Indian_Railways.svg/1200px-Indian_Railways.svg.png" alt="Indian Railways Logo" class="h-12 mr-3"> | |
| <h1 class="text-2xl font-bold">INDIAN RAILWAYS TRAIN SIMULATOR</h1> | |
| </div> | |
| <div class="flex items-center space-x-4"> | |
| <div class="bg-black bg-opacity-50 px-3 py-1 rounded-full flex items-center"> | |
| <i class="fas fa-rupee-sign text-yellow-400 mr-2"></i> | |
| <span id="score">12,450</span> | |
| </div> | |
| <div class="bg-black bg-opacity-50 px-3 py-1 rounded-full flex items-center"> | |
| <i class="fas fa-user-tie text-blue-400 mr-2"></i> | |
| <span>Asst. Loco Pilot</span> | |
| </div> | |
| <button class="bg-yellow-500 hover:bg-yellow-600 text-black px-4 py-1 rounded-full font-semibold"> | |
| <i class="fas fa-cog mr-2"></i>Settings | |
| </button> | |
| </div> | |
| </header> | |
| <!-- Main Game Area --> | |
| <main class="flex-1 flex overflow-hidden relative"> | |
| <!-- Left Panel - Controls --> | |
| <div class="w-80 bg-gray-900 p-4 flex flex-col border-r border-gray-700"> | |
| <div class="cabin-panel p-4 mb-4"> | |
| <h2 class="text-lg font-semibold mb-3 text-center border-b border-gray-600 pb-2">LOCO CONTROLS</h2> | |
| <div class="mb-4"> | |
| <div class="flex justify-between items-center mb-1"> | |
| <span class="text-sm">THROTTLE</span> | |
| <span class="text-xs bg-blue-900 px-2 py-1 rounded" id="throttle-value">0%</span> | |
| </div> | |
| <input type="range" min="0" max="100" value="0" class="w-full h-2 bg-gray-700 rounded-lg appearance-none cursor-pointer" id="throttle"> | |
| </div> | |
| <div class="mb-4"> | |
| <div class="flex justify-between items-center mb-1"> | |
| <span class="text-sm">BRAKE</span> | |
| <span class="text-xs bg-red-900 px-2 py-1 rounded" id="brake-value">0%</span> | |
| </div> | |
| <input type="range" min="0" max="100" value="0" class="w-full h-2 bg-gray-700 rounded-lg appearance-none cursor-pointer" id="brake"> | |
| </div> | |
| <div class="grid grid-cols-3 gap-3 mb-4"> | |
| <button class="bg-blue-700 hover:bg-blue-600 py-2 rounded button-glow" id="horn"> | |
| <i class="fas fa-bullhorn"></i> | |
| <div class="text-xs mt-1">HORN</div> | |
| </button> | |
| <button class="bg-gray-700 hover:bg-gray-600 py-2 rounded button-glow" id="headlight"> | |
| <i class="fas fa-lightbulb"></i> | |
| <div class="text-xs mt-1">LIGHTS</div> | |
| </button> | |
| <button class="bg-green-700 hover:bg-green-600 py-2 rounded button-glow" id="pantograph"> | |
| <i class="fas fa-bolt"></i> | |
| <div class="text-xs mt-1">PANTO</div> | |
| </button> | |
| <button class="bg-purple-700 hover:bg-purple-600 py-2 rounded button-glow" id="doors"> | |
| <i class="fas fa-door-open"></i> | |
| <div class="text-xs mt-1">DOORS</div> | |
| </button> | |
| <button class="bg-yellow-700 hover:bg-yellow-600 py-2 rounded button-glow" id="sand"> | |
| <i class="fas fa-filter"></i> | |
| <div class="text-xs mt-1">SAND</div> | |
| </button> | |
| <button class="bg-red-700 hover:bg-red-600 py-2 rounded button-glow" id="emergency"> | |
| <i class="fas fa-exclamation-triangle"></i> | |
| <div class="text-xs mt-1">E-STOP</div> | |
| </button> | |
| </div> | |
| <div class="border-t border-gray-600 pt-3"> | |
| <div class="flex justify-between text-sm mb-1"> | |
| <span>SPEED</span> | |
| <span id="speed-value">0 km/h</span> | |
| </div> | |
| <div class="h-2 bg-gray-700 rounded-full mb-3"> | |
| <div class="h-2 bg-green-500 rounded-full" id="speed-bar" style="width: 0%"></div> | |
| </div> | |
| <div class="flex justify-between text-sm mb-1"> | |
| <span>POWER</span> | |
| <span id="power-value">0%</span> | |
| </div> | |
| <div class="h-2 bg-gray-700 rounded-full"> | |
| <div class="h-2 bg-blue-500 rounded-full" id="power-bar" style="width: 0%"></div> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="cabin-panel p-4 mb-4"> | |
| <h2 class="text-lg font-semibold mb-3 text-center border-b border-gray-600 pb-2">TRAIN INFO</h2> | |
| <div class="space-y-2"> | |
| <div class="flex justify-between"> | |
| <span class="text-gray-400">Train No.:</span> | |
| <span>12952</span> | |
| </div> | |
| <div class="flex justify-between"> | |
| <span class="text-gray-400">Name:</span> | |
| <span>Rajdhani Express</span> | |
| </div> | |
| <div class="flex justify-between"> | |
| <span class="text-gray-400">Loco:</span> | |
| <span>WAP-7 #30242</span> | |
| </div> | |
| <div class="flex justify-between"> | |
| <span class="text-gray-400">Route:</span> | |
| <span>NDLS - CSTM</span> | |
| </div> | |
| <div class="flex justify-between"> | |
| <span class="text-gray-400">Next Stop:</span> | |
| <span class="text-yellow-300">Bhopal (BPL)</span> | |
| </div> | |
| <div class="flex justify-between"> | |
| <span class="text-gray-400">Distance:</span> | |
| <span>148.3 km</span> | |
| </div> | |
| <div class="flex justify-between"> | |
| <span class="text-gray-400">Time:</span> | |
| <span>2h 18m</span> | |
| </div> | |
| <div class="flex justify-between"> | |
| <span class="text-gray-400">Punctuality:</span> | |
| <span class="text-green-400">+3 min</span> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="cabin-panel p-4 flex-1"> | |
| <h2 class="text-lg font-semibold mb-3 text-center border-b border-gray-600 pb-2">SIGNALS & ATC</h2> | |
| <div class="flex justify-center mb-4"> | |
| <div class="signal-red w-8 h-8 rounded-full bg-red-600 border border-gray-400 mr-2"></div> | |
| <div class="signal-yellow w-8 h-8 rounded-full bg-yellow-500 border border-gray-400 mr-2"></div> | |
| <div class="signal-green w-8 h-8 rounded-full bg-green-500 border border-gray-400"></div> | |
| </div> | |
| <div class="bg-black bg-opacity-50 p-2 rounded mb-3"> | |
| <div class="text-xs text-gray-400 mb-1">CURRENT SIGNAL</div> | |
| <div class="text-xl font-mono text-center blinking">RED</div> | |
| </div> | |
| <div class="bg-black bg-opacity-50 p-2 rounded"> | |
| <div class="text-xs text-gray-400 mb-1">ATC SPEED LIMIT</div> | |
| <div class="text-xl font-mono text-center">110 km/h</div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Center Panel - Game View --> | |
| <div class="flex-1 relative overflow-hidden"> | |
| <!-- Weather effects will be added here dynamically --> | |
| <div id="weather-effects"></div> | |
| <!-- Canvas for 3D rendering --> | |
| <canvas id="gameCanvas" class="absolute inset-0 w-full h-full"></canvas> | |
| <!-- Station Announcement Banner --> | |
| <div class="absolute bottom-4 left-1/2 transform -translate-x-1/2 bg-black bg-opacity-70 px-6 py-2 rounded-full flex items-center"> | |
| <i class="fas fa-bullhorn text-yellow-400 mr-3"></i> | |
| <div class="marquee"> | |
| <span class="announcement-text">Attention please! Train number 12952 Rajdhani Express arriving shortly on platform number 3. Passengers are requested to...</span> | |
| </div> | |
| </div> | |
| <!-- Speed Limit Indicator --> | |
| <div class="absolute top-4 right-4 bg-black bg-opacity-70 border-2 border-white rounded-full w-16 h-16 flex items-center justify-center"> | |
| <div class="text-2xl font-bold">110</div> | |
| </div> | |
| <!-- Mini Map --> | |
| <div class="absolute top-4 left-1/2 transform -translate-x-1/2 bg-black bg-opacity-50 p-2 rounded-lg"> | |
| <div class="w-48 h-24 bg-gray-800 relative"> | |
| <div class="absolute inset-0 bg-green-900 opacity-30"></div> | |
| <div class="absolute top-1/2 left-0 right-0 h-1 bg-yellow-400"></div> | |
| <div class="absolute top-1/2 left-1/4 transform -translate-y-1/2 -translate-x-1/2 w-2 h-2 bg-white rounded-full"></div> | |
| <div class="absolute top-1/2 left-3/4 transform -translate-y-1/2 -translate-x-1/2 w-3 h-3 bg-red-500 rounded-full"></div> | |
| <div class="absolute bottom-1 left-2 text-xs">BPL</div> | |
| <div class="absolute bottom-1 right-2 text-xs">NDLS</div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Right Panel - Coach View and Tasks --> | |
| <div class="w-80 bg-gray-900 p-4 flex flex-col border-l border-gray-700"> | |
| <div class="cabin-panel p-4 mb-4"> | |
| <h2 class="text-lg font-semibold mb-3 text-center border-b border-gray-600 pb-2">COACH VIEW</h2> | |
| <div class="flex overflow-x-auto pb-2 space-x-2"> | |
| <div class="flex-shrink-0 w-16 h-24 bg-blue-900 rounded flex flex-col items-center justify-center"> | |
| <div class="w-12 h-16 train-body mb-1"></div> | |
| <div class="text-xs">WAP-7</div> | |
| </div> | |
| <div class="flex-shrink-0 w-16 h-24 bg-blue-900 rounded flex flex-col items-center justify-center"> | |
| <div class="w-12 h-16 coach-body mb-1"></div> | |
| <div class="text-xs">S1</div> | |
| </div> | |
| <div class="flex-shrink-0 w-16 h-24 bg-blue-900 rounded flex flex-col items-center justify-center"> | |
| <div class="w-12 h-16 coach-body mb-1"></div> | |
| <div class="text-xs">S2</div> | |
| </div> | |
| <div class="flex-shrink-0 w-16 h-24 bg-blue-900 rounded flex flex-col items-center justify-center"> | |
| <div class="w-12 h-16 coach-body mb-1"></div> | |
| <div class="text-xs">S3</div> | |
| </div> | |
| <div class="flex-shrink-0 w-16 h-24 bg-blue-900 rounded flex flex-col items-center justify-center"> | |
| <div class="w-12 h-16 coach-body mb-1"></div> | |
| <div class="text-xs">S4</div> | |
| </div> | |
| <div class="flex-shrink-0 w-16 h-24 bg-blue-900 rounded flex flex-col items-center justify-center"> | |
| <div class="w-12 h-16 coach-body mb-1"></div> | |
| <div class="text-xs">S5</div> | |
| </div> | |
| </div> | |
| <div class="mt-4 bg-black bg-opacity-30 p-2 rounded"> | |
| <div class="flex justify-between text-sm mb-1"> | |
| <span class="text-gray-400">Passengers:</span> | |
| <span>432/480</span> | |
| </div> | |
| <div class="h-2 bg-gray-700 rounded-full"> | |
| <div class="h-2 bg-green-500 rounded-full" style="width: 90%"></div> | |
| </div> | |
| <div class="flex justify-between text-sm mt-2"> | |
| <span class="text-gray-400">Satisfaction:</span> | |
| <span class="text-yellow-300">84%</span> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="cabin-panel p-4 mb-4 flex-1"> | |
| <h2 class="text-lg font-semibold mb-3 text-center border-b border-gray-600 pb-2">TASKS & OBJECTIVES</h2> | |
| <div class="space-y-3"> | |
| <div class="flex items-start"> | |
| <div class="w-5 h-5 rounded-full bg-green-500 flex items-center justify-center mr-2 mt-0.5"> | |
| <i class="fas fa-check text-xs text-white"></i> | |
| </div> | |
| <div> | |
| <div class="text-sm">Depart New Delhi on time</div> | |
| <div class="text-xs text-gray-400">+250 points</div> | |
| </div> | |
| </div> | |
| <div class="flex items-start"> | |
| <div class="w-5 h-5 rounded-full bg-green-500 flex items-center justify-center mr-2 mt-0.5"> | |
| <i class="fas fa-check text-xs text-white"></i> | |
| </div> | |
| <div> | |
| <div class="text-sm">Maintain speed through Ghaziabad</div> | |
| <div class="text-xs text-gray-400">+180 points</div> | |
| </div> | |
| </div> | |
| <div class="flex items-start"> | |
| <div class="w-5 h-5 rounded-full bg-yellow-500 flex items-center justify-center mr-2 mt-0.5"> | |
| <i class="fas fa-spinner text-xs text-white"></i> | |
| </div> | |
| <div> | |
| <div class="text-sm">Arrive Bhopal within ±5 minutes</div> | |
| <div class="text-xs text-gray-400">0/300 points</div> | |
| </div> | |
| </div> | |
| <div class="flex items-start"> | |
| <div class="w-5 h-5 rounded-full bg-gray-600 flex items-center justify-center mr-2 mt-0.5"> | |
| <i class="fas fa-clock text-xs text-white"></i> | |
| </div> | |
| <div> | |
| <div class="text-sm">Complete journey to Mumbai</div> | |
| <div class="text-xs text-gray-400">0/1000 points</div> | |
| </div> | |
| </div> | |
| <div class="flex items-start"> | |
| <div class="w-5 h-5 rounded-full bg-gray-600 flex items-center justify-center mr-2 mt-0.5"> | |
| <i class="fas fa-clock text-xs text-white"></i> | |
| </div> | |
| <div> | |
| <div class="text-sm">Keep passenger satisfaction >80%</div> | |
| <div class="text-xs text-gray-400">0/400 points</div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="cabin-panel p-4"> | |
| <h2 class="text-lg font-semibold mb-3 text-center border-b border-gray-600 pb-2">ENVIRONMENT</h2> | |
| <div class="grid grid-cols-3 gap-2 mb-3"> | |
| <button class="bg-blue-800 hover:bg-blue-700 py-2 rounded" id="weather-clear"> | |
| <i class="fas fa-sun"></i> | |
| <div class="text-xs mt-1">CLEAR</div> | |
| </button> | |
| <button class="bg-gray-700 hover:bg-gray-600 py-2 rounded" id="weather-fog"> | |
| <i class="fas fa-smog"></i> | |
| <div class="text-xs mt-1">FOG</div> | |
| </button> | |
| <button class="bg-indigo-800 hover:bg-indigo-700 py-2 rounded" id="weather-rain"> | |
| <i class="fas fa-cloud-rain"></i> | |
| <div class="text-xs mt-1">RAIN</div> | |
| </button> | |
| </div> | |
| <div class="flex justify-between items-center"> | |
| <div> | |
| <div class="text-sm">TIME OF DAY</div> | |
| <div class="text-xs text-gray-400" id="time-display">10:42 AM</div> | |
| </div> | |
| <input type="range" min="0" max="1439" value="642" class="w-32 h-1 bg-gray-700 rounded-lg appearance-none cursor-pointer" id="time-slider"> | |
| </div> | |
| </div> | |
| </div> | |
| </main> | |
| <!-- Bottom Status Bar --> | |
| <footer class="bg-gray-800 py-1 px-4 flex justify-between items-center text-sm border-t border-gray-700"> | |
| <div class="flex items-center space-x-4"> | |
| <div class="flex items-center"> | |
| <div class="w-3 h-3 rounded-full bg-green-500 mr-2"></div> | |
| <span>POWER: ON</span> | |
| </div> | |
| <div class="flex items-center"> | |
| <div class="w-3 h-3 rounded-full bg-red-500 mr-2"></div> | |
| <span>PANTO: DOWN</span> | |
| </div> | |
| <div class="flex items-center"> | |
| <div class="w-3 h-3 rounded-full bg-yellow-500 mr-2"></div> | |
| <span>DOORS: LOCKED</span> | |
| </div> | |
| </div> | |
| <div class="flex items-center space-x-4"> | |
| <div class="flex items-center"> | |
| <i class="fas fa-map-marker-alt text-red-400 mr-2"></i> | |
| <span>KM 342.7 • BPL 148.3 km</span> | |
| </div> | |
| <div class="flex items-center"> | |
| <i class="fas fa-clock text-blue-400 mr-2"></i> | |
| <span>DELAY: +3 min</span> | |
| </div> | |
| </div> | |
| </footer> | |
| <script> | |
| // Game state | |
| const gameState = { | |
| speed: 0, | |
| throttle: 0, | |
| brake: 0, | |
| power: 0, | |
| pantograph: false, | |
| headlights: false, | |
| doors: false, | |
| weather: 'clear', | |
| time: 642, // 10:42 AM in minutes | |
| signal: 'red', | |
| score: 12450, | |
| announcements: [ | |
| "Attention please! Train number 12952 Rajdhani Express arriving shortly on platform number 3.", | |
| "Passengers are requested to board the train only after it comes to a complete halt.", | |
| "Please keep your belongings safe and secure during the journey.", | |
| "The next station is Bhopal Junction. We will arrive in approximately 2 hours.", | |
| "Lunch will be served shortly in all AC coaches. Please contact your coach attendant.", | |
| "This is a non-smoking train. Smoking is strictly prohibited.", | |
| "Passengers are requested to cooperate with railway staff for a comfortable journey." | |
| ], | |
| currentAnnouncement: 0 | |
| }; | |
| // DOM elements | |
| const elements = { | |
| throttle: document.getElementById('throttle'), | |
| throttleValue: document.getElementById('throttle-value'), | |
| brake: document.getElementById('brake'), | |
| brakeValue: document.getElementById('brake-value'), | |
| horn: document.getElementById('horn'), | |
| headlight: document.getElementById('headlight'), | |
| pantograph: document.getElementById('pantograph'), | |
| doors: document.getElementById('doors'), | |
| emergency: document.getElementById('emergency'), | |
| speedValue: document.getElementById('speed-value'), | |
| speedBar: document.getElementById('speed-bar'), | |
| powerValue: document.getElementById('power-value'), | |
| powerBar: document.getElementById('power-bar'), | |
| weatherEffects: document.getElementById('weather-effects'), | |
| weatherClear: document.getElementById('weather-clear'), | |
| weatherFog: document.getElementById('weather-fog'), | |
| weatherRain: document.getElementById('weather-rain'), | |
| timeSlider: document.getElementById('time-slider'), | |
| timeDisplay: document.getElementById('time-display'), | |
| score: document.getElementById('score'), | |
| announcementText: document.querySelector('.announcement-text') | |
| }; | |
| // Initialize canvas | |
| const canvas = document.getElementById('gameCanvas'); | |
| const ctx = canvas.getContext('2d'); | |
| function resizeCanvas() { | |
| canvas.width = canvas.offsetWidth; | |
| canvas.height = canvas.offsetHeight; | |
| renderScene(); | |
| } | |
| window.addEventListener('resize', resizeCanvas); | |
| resizeCanvas(); | |
| // Event listeners for controls | |
| elements.throttle.addEventListener('input', function() { | |
| gameState.throttle = parseInt(this.value); | |
| elements.throttleValue.textContent = `${gameState.throttle}%`; | |
| updatePower(); | |
| }); | |
| elements.brake.addEventListener('input', function() { | |
| gameState.brake = parseInt(this.value); | |
| elements.brakeValue.textContent = `${gameState.brake}%`; | |
| updateSpeed(); | |
| }); | |
| elements.horn.addEventListener('click', function() { | |
| playHornSound(); | |
| // Visual feedback | |
| this.classList.add('bg-blue-600'); | |
| setTimeout(() => { | |
| this.classList.remove('bg-blue-600'); | |
| }, 200); | |
| }); | |
| elements.headlight.addEventListener('click', function() { | |
| gameState.headlights = !gameState.headlights; | |
| this.classList.toggle('bg-gray-600'); | |
| this.classList.toggle('bg-blue-600'); | |
| renderScene(); | |
| }); | |
| elements.pantograph.addEventListener('click', function() { | |
| gameState.pantograph = !gameState.pantograph; | |
| this.classList.toggle('bg-green-600'); | |
| this.classList.toggle('bg-gray-600'); | |
| updatePower(); | |
| }); | |
| elements.doors.addEventListener('click', function() { | |
| gameState.doors = !gameState.doors; | |
| this.classList.toggle('bg-purple-600'); | |
| this.classList.toggle('bg-gray-600'); | |
| }); | |
| elements.emergency.addEventListener('click', function() { | |
| gameState.brake = 100; | |
| elements.brake.value = 100; | |
| elements.brakeValue.textContent = '100%'; | |
| updateSpeed(); | |
| // Visual feedback | |
| this.classList.add('bg-red-800'); | |
| setTimeout(() => { | |
| this.classList.remove('bg-red-800'); | |
| }, 1000); | |
| }); | |
| elements.weatherClear.addEventListener('click', function() { | |
| gameState.weather = 'clear'; | |
| updateWeather(); | |
| }); | |
| elements.weatherFog.addEventListener('click', function() { | |
| gameState.weather = 'fog'; | |
| updateWeather(); | |
| }); | |
| elements.weatherRain.addEventListener('click', function() { | |
| gameState.weather = 'rain'; | |
| updateWeather(); | |
| }); | |
| elements.timeSlider.addEventListener('input', function() { | |
| gameState.time = parseInt(this.value); | |
| updateTimeDisplay(); | |
| renderScene(); | |
| }); | |
| // Game logic functions | |
| function updatePower() { | |
| if (gameState.pantograph) { | |
| gameState.power = Math.floor(gameState.throttle * 0.9 - gameState.brake * 0.2); | |
| if (gameState.power < 0) gameState.power = 0; | |
| } else { | |
| gameState.power = 0; | |
| } | |
| elements.powerValue.textContent = `${gameState.power}%`; | |
| elements.powerBar.style.width = `${gameState.power}%`; | |
| updateSpeed(); | |
| } | |
| function updateSpeed() { | |
| // Simplified physics - in a real game this would be more complex | |
| const acceleration = gameState.power * 0.02; | |
| const deceleration = gameState.brake * 0.05 + 0.1; // Base friction + brake | |
| gameState.speed += acceleration - deceleration; | |
| if (gameState.speed < 0) gameState.speed = 0; | |
| if (gameState.speed > 110) gameState.speed = 110; // Speed limit | |
| elements.speedValue.textContent = `${Math.round(gameState.speed)} km/h`; | |
| elements.speedBar.style.width = `${(gameState.speed / 110) * 100}%`; | |
| // Update score based on speed (simplified) | |
| if (gameState.speed > 0) { | |
| gameState.score += Math.floor(gameState.speed / 10); | |
| elements.score.textContent = gameState.score.toLocaleString(); | |
| } | |
| } | |
| function updateWeather() { | |
| elements.weatherEffects.innerHTML = ''; | |
| switch (gameState.weather) { | |
| case 'fog': | |
| const fog = document.createElement('div'); | |
| fog.className = 'fog-effect'; | |
| elements.weatherEffects.appendChild(fog); | |
| break; | |
| case 'rain': | |
| const rain = document.createElement('div'); | |
| rain.className = 'rain-effect'; | |
| elements.weatherEffects.appendChild(rain); | |
| break; | |
| } | |
| // Update button states | |
| elements.weatherClear.classList.remove('bg-blue-700', 'bg-blue-800'); | |
| elements.weatherFog.classList.remove('bg-gray-700', 'bg-gray-800'); | |
| elements.weatherRain.classList.remove('bg-indigo-700', 'bg-indigo-800'); | |
| if (gameState.weather === 'clear') { | |
| elements.weatherClear.classList.add('bg-blue-700'); | |
| } else { | |
| elements.weatherClear.classList.add('bg-blue-800'); | |
| } | |
| if (gameState.weather === 'fog') { | |
| elements.weatherFog.classList.add('bg-gray-700'); | |
| } else { | |
| elements.weatherFog.classList.add('bg-gray-800'); | |
| } | |
| if (gameState.weather === 'rain') { | |
| elements.weatherRain.classList.add('bg-indigo-700'); | |
| } else { | |
| elements.weatherRain.classList.add('bg-indigo-800'); | |
| } | |
| renderScene(); | |
| } | |
| function updateTimeDisplay() { | |
| const hours = Math.floor(gameState.time / 60); | |
| const minutes = gameState.time % 60; | |
| const ampm = hours >= 12 ? 'PM' : 'AM'; | |
| const displayHours = hours % 12 || 12; | |
| elements.timeDisplay.textContent = | |
| `${displayHours}:${minutes.toString().padStart(2, '0')} ${ampm}`; | |
| } | |
| function playHornSound() { | |
| // In a real implementation, we would play an actual sound | |
| console.log("Horn sound played!"); | |
| } | |
| function cycleAnnouncements() { | |
| elements.announcementText.textContent = gameState.announcements[gameState.currentAnnouncement]; | |
| gameState.currentAnnouncement = (gameState.currentAnnouncement + 1) % gameState.announcements.length; | |
| // Random interval between announcements (15-45 seconds) | |
| setTimeout(cycleAnnouncements, 15000 + Math.random() * 30000); | |
| } | |
| // Render the 3D scene (simplified 2D representation) | |
| function renderScene() { | |
| ctx.clearRect(0, 0, canvas.width, canvas.height); | |
| // Background based on time of day | |
| const hour = gameState.time / 60; | |
| let bgColor; | |
| if (hour < 5 || hour >= 19) { | |
| // Night | |
| bgColor = '#0f172a'; | |
| } else if (hour < 6 || hour >= 18) { | |
| // Dawn/Dusk | |
| bgColor = '#1e40af'; | |
| } else { | |
| // Day | |
| bgColor = '#38bdf8'; | |
| } | |
| ctx.fillStyle = bgColor; | |
| ctx.fillRect(0, 0, canvas.width, canvas.height); | |
| // Draw horizon | |
| ctx.fillStyle = hour < 6 || hour >= 18 ? '#1e293b' : '#475569'; | |
| ctx.fillRect(0, canvas.height * 0.7, canvas.width, canvas.height * 0.3); | |
| // Draw tracks | |
| ctx.fillStyle = '#4b5563'; | |
| ctx.fillRect(0, canvas.height * 0.8, canvas.width, 10); | |
| // Draw sleepers | |
| ctx.fillStyle = '#6b7280'; | |
| for (let x = 0; x < canvas.width; x += 40) { | |
| ctx.fillRect(x, canvas.height * 0.8 - 5, 30, 5); | |
| } | |
| // Draw platform if at station | |
| if (gameState.speed === 0) { | |
| ctx.fillStyle = '#9ca3af'; | |
| ctx.fillRect(0, canvas.height * 0.7 - 20, canvas.width, 20); | |
| // Platform tiles | |
| ctx.fillStyle = '#d1d5db'; | |
| for (let x = 0; x < canvas.width; x += 40) { | |
| ctx.fillRect(x, canvas.height * 0.7 - 20, 20, 20); | |
| } | |
| // Draw passengers | |
| for (let i = 0; i < 5; i++) { | |
| const x = Math.random() * canvas.width; | |
| const y = canvas.height * 0.7 - 25; | |
| drawPassenger(x, y); | |
| } | |
| } | |
| // Draw train | |
| drawTrain(); | |
| // Draw signals | |
| drawSignal(canvas.width * 0.8, canvas.height * 0.6); | |
| // Draw scenery elements | |
| if (gameState.speed > 0) { | |
| // Moving scenery | |
| for (let i = 0; i < 3; i++) { | |
| const x = Math.random() * canvas.width; | |
| const y = canvas.height * 0.6; | |
| drawSceneryElement(x, y); | |
| } | |
| } | |
| } | |
| function drawTrain() { | |
| const trainLength = 200 + (gameState.speed / 10); | |
| const trainX = canvas.width * 0.2; | |
| const trainY = canvas.height * 0.7 - 50; | |
| // Locomotive | |
| ctx.fillStyle = '#d10a11'; | |
| ctx.fillRect(trainX, trainY, 80, 50); | |
| ctx.fillStyle = 'white'; | |
| ctx.fillRect(trainX + 48, trainY, 32, 50); | |
| // Windows | |
| ctx.fillStyle = '#1e293b'; | |
| for (let i = 0; i < 3; i++) { | |
| ctx.fillRect(trainX + 10 + i * 20, trainY + 10, 15, 15); | |
| } | |
| // Headlight if on | |
| if (gameState.headlights) { | |
| ctx.fillStyle = 'rgba(255, 255, 255, 0.7)'; | |
| ctx.beginPath(); | |
| ctx.moveTo(trainX + 80, trainY + 25); | |
| ctx.lineTo(trainX + 120, trainY + 10); | |
| ctx.lineTo(trainX + 120, trainY + 40); | |
| ctx.closePath(); | |
| ctx.fill(); | |
| } | |
| // Coaches | |
| for (let i = 0; i < 5; i++) { | |
| ctx.fillStyle = '#003580'; | |
| ctx.fillRect(trainX + 80 + i * 40, trainY, 40, 50); | |
| ctx.fillStyle = 'white'; | |
| ctx.fillRect(trainX + 80 + i * 40 + 24, trainY, 16, 50); | |
| // Windows | |
| ctx.fillStyle = '#1e293b'; | |
| for (let j = 0; j < 2; j++) { | |
| ctx.fillRect(trainX + 80 + i * 40 + 5 + j * 15, trainY + 10, 10, 15); | |
| } | |
| // Coach number | |
| ctx.fillStyle = 'white'; | |
| ctx.font = '10px Arial'; | |
| ctx.fillText(`S${i+1}`, trainX + 80 + i * 40 + 15, trainY + 40); | |
| } | |
| } | |
| function drawSignal(x, y) { | |
| // Post | |
| ctx.fillStyle = '#57534e'; | |
| ctx.fillRect(x, y, 10, 100); | |
| // Housing | |
| ctx.fillStyle = '#1e293b'; | |
| ctx.fillRect(x - 15, y - 30, 40, 30); | |
| // Lights | |
| const colors = { | |
| red: gameState.signal === 'red' ? '#ef4444' : '#450a0a', | |
| yellow: gameState.signal === 'yellow' ? '#eab308' : '#422006', | |
| green: gameState.signal === 'green' ? '#22c55e' : '#052e16' | |
| }; | |
| ctx.beginPath(); | |
| ctx.arc(x + 5, y - 20, 5, 0, Math.PI * 2); | |
| ctx.fillStyle = colors.red; | |
| ctx.fill(); | |
| ctx.beginPath(); | |
| ctx.arc(x + 5, y - 10, 5, 0, Math.PI * 2); | |
| ctx.fillStyle = colors.yellow; | |
| ctx.fill(); | |
| ctx.beginPath(); | |
| ctx.arc(x + 5, y, 5, 0, Math.PI * 2); | |
| ctx.fillStyle = colors.green; | |
| ctx.fill(); | |
| } | |
| function drawPassenger(x, y) { | |
| // Head | |
| ctx.beginPath(); | |
| ctx.arc(x, y, 5, 0, Math.PI * 2); | |
| ctx.fillStyle = '#f59e0b'; | |
| ctx.fill(); | |
| // Body | |
| ctx.fillStyle = '#4b5563'; | |
| ctx.fillRect(x - 5, y + 5, 10, 15); | |
| // Legs | |
| ctx.fillRect(x - 5, y + 20, 4, 10); | |
| ctx.fillRect(x + 1, y + 20, 4, 10); | |
| } | |
| function drawSceneryElement(x, y) { | |
| const types = ['tree', 'building', 'cow']; | |
| const type = types[Math.floor(Math.random() * types.length)]; | |
| switch (type) { | |
| case 'tree': | |
| // Trunk | |
| ctx.fillStyle = '#78350f'; | |
| ctx.fillRect(x, y, 5, 20); | |
| // Leaves | |
| ctx.beginPath(); | |
| ctx.arc(x + 2, y - 10, 15, 0, Math.PI * 2); | |
| ctx.fillStyle = '#166534'; | |
| ctx.fill(); | |
| break; | |
| case 'building': | |
| ctx.fillStyle = '#475569'; | |
| const height = 30 + Math.random() * 30; | |
| const width = 20 + Math.random() * 20; | |
| ctx.fillRect(x, y - height, width, height); | |
| // Windows | |
| ctx.fillStyle = '#fef08a'; | |
| for (let i = 0; i < 2; i++) { | |
| for (let j = 0; j < 2; j++) { | |
| if (Math.random() > 0.3) { | |
| ctx.fillRect(x + 5 + i * 8, y - height + 5 + j * 8, 5, 5); | |
| } | |
| } | |
| } | |
| break; | |
| case 'cow': | |
| // Body | |
| ctx.beginPath(); | |
| ctx.ellipse(x, y, 10, 5, 0, 0, Math.PI * 2); | |
| ctx.fillStyle = '#6b7280'; | |
| ctx.fill(); | |
| // Head | |
| ctx.beginPath(); | |
| ctx.arc(x - 12, y - 3, 4, 0, Math.PI * 2); | |
| ctx.fillStyle = '#6b7280'; | |
| ctx.fill(); | |
| // Spots | |
| ctx.beginPath(); | |
| ctx.arc(x + 2, y - 2, 3, 0, Math.PI * 2); | |
| ctx.fillStyle = '#9ca3af'; | |
| ctx.fill(); | |
| break; | |
| } | |
| } | |
| // Game loop | |
| function gameLoop() { | |
| updateSpeed(); | |
| renderScene(); | |
| // Random signal changes | |
| if (Math.random() < 0.005) { | |
| const signals = ['red', 'yellow', 'green']; | |
| gameState.signal = signals[Math.floor(Math.random() * signals.length)]; | |
| } | |
| requestAnimationFrame(gameLoop); | |
| } | |
| // Initialize game | |
| updateWeather(); | |
| updateTimeDisplay(); | |
| cycleAnnouncements(); | |
| gameLoop(); | |
| // Simulate random AI train horns | |
| setInterval(() => { | |
| if (Math.random() > 0.7) { | |
| playHornSound(); | |
| } | |
| }, 10000 + Math.random() * 20000); | |
| </script> | |
| <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=div988/train" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body> | |
| </html> |