Forgotten Realms: Survival Adventure
Health:
Stamina:
Temperature:
Hunger:
Day 1 - 12:00
Clear
Inventory:
Wood: 0 | Stone: 0 | Metal: 0
Press E to interact
]]>
{ this.camera.aspect = window.innerWidth / window.innerHeight; this.camera.updateProjectionMatrix(); this.renderer.setSize(window.innerWidth, window.innerHeight); }); // Interaction controls document.addEventListener('keydown', (event) => { if (event.key.toLowerCase() === 'e') { this.interactionSystem.tryInteract(); } }); } updateLighting() { const timeInfo = this.timeSystem.getTimeInfo(); // Update sun position and color based on time const sunAngle = (timeInfo.hours / 24) * Math.PI * 2 - Math.PI / 2; this.sunLight.position.x = Math.cos(sunAngle) * 100; this.sunLight.position.y = Math.sin(sunAngle) * 100 + 20; // Adjust lighting intensity and color let intensity = Math.max(0.1, Math.sin(sunAngle) * 0.8 + 0.2); let color = new THREE.Color(); if (timeInfo.hours < 6 || timeInfo.hours > 20) { // Night time - blue tint color.setHSL(0.6, 0.8, 0.3); intensity *= 0.3; this.ambientLight.intensity = 0.6; } else if (timeInfo.hours < 8 || timeInfo.hours > 18) { // Dawn/dusk - orange tint color.setHSL(0.08, 0.9, 0.6); this.ambientLight.intensity = 0.4; } else { // Day time - natural white color.setHSL(0.1, 0.2, 1); this.ambientLight.intensity = 0.4; } this.sunLight.color.copy(color); this.sunLight.intensity = intensity; } animate() { requestAnimationFrame(() => this.animate()); const deltaTime = this.clock.getDelta(); // Update systems const cameraRotation = this.cameraController.update(); this.playerController.update(deltaTime, cameraRotation); this.survivalSystem.update(deltaTime); this.timeSystem.update(deltaTime); this.interactionSystem.update(); // Update lighting based on time this.updateLighting(); // Update UI this.updateUI(); this.renderer.render(this.scene, this.camera); } updateUI() { const stats = this.survivalSystem.getStats(); const timeInfo = this.timeSystem.getTimeInfo(); const inventory = this.survivalSystem.getInventory(); // Update stat bars document.getElementById('health-bar').style.width = (stats.health / 100) * 100 + '%'; document.getElementById('stamina-bar').style.width = (stats.stamina / 100) * 100 + '%'; document.getElementById('temperature-bar').style.width = (stats.temperature / 100) * 100 + '%'; document.getElementById('hunger-bar').style.width = (stats.hunger / 100) * 100 + '%'; // Update time display const hours = Math.floor(timeInfo.hours).toString().padStart(2, '0'); const minutes = Math.floor((timeInfo.hours % 1) * 60).toString().padStart(2, '0'); document.getElementById('time-info').textContent = `Day ${timeInfo.day} - ${hours}:${minutes}`; document.getElementById('weather-info').textContent = timeInfo.weather; // Update inventory document.getElementById('inventory-items').textContent = `Wood: ${inventory.wood} | Stone: ${inventory.stone} | Metal: ${inventory.metal}`; // Update interaction prompt const canInteract = this.interactionSystem.getNearbyInteractable(); const prompt = document.getElementById('interaction-prompt'); if (canInteract) { prompt.style.display = 'block'; prompt.textContent = `Press E to ${canInteract.action}`; } else { prompt.style.display = 'none'; } } } // Start the game new SurvivalGame(); ]]> 1000) { // 1 second after last use this.stats.stamina = Math.min(100