Kategoriler
Alışveriş Sepetiniz

Collect Coins Game

Coin Hunter: Time Vaults
Coins: 0/12
Time Vault Explorer
WASD - Move around
Mouse - Look around
E - Interact with objects
TAB - Toggle collection view
R - Return to Hub

Coin Collection

Time Vault Laboratory
]]>
this.onWindowResize());// Make game accessible globally for UI window.game = this; }setupInput() { document.addEventListener('keydown', (event) => { switch(event.code) { case 'KeyE': this.handleInteraction(); break; case 'Tab': event.preventDefault(); this.toggleCoinInfo(); break; case 'KeyR': this.returnToHub(); break; } }); }handleInteraction() { const playerPos = this.player.position; if (this.currentEnvironment === 'hub') { // Check for portal interaction const portalPos = new THREE.Vector3(0, 0, -8); if (playerPos.distanceTo(portalPos) < 3) { this.switchToRome(); } } else if (this.currentEnvironment === 'rome') { // Check for coin collection this.game.checkCoinCollection(playerPos); } }loadEnvironment(env) { // Clear current environment this.scene.clear(); this.scene.add(this.player);if (env === 'hub') { this.hubEnvironment.load(); this.player.position.set(0, 1.6, 5); this.showEraTitle('Time Vault Laboratory', 'Your workshop for interdimensional coin hunting'); } else if (env === 'rome') { this.romeEnvironment.load(); this.player.position.set(0, 1.6, 8); this.showEraTitle('Ancient Rome - 50 BCE', 'The heart of the Roman Empire'); } this.currentEnvironment = env; }switchToRome() { this.loadEnvironment('rome'); }returnToHub() { this.loadEnvironment('hub'); }showEraTitle(title, subtitle) { const eraTitle = document.getElementById('eraTitle'); document.getElementById('eraName').innerHTML = `${title}
${subtitle}`; eraTitle.style.display = 'block'; setTimeout(() => { eraTitle.style.display = 'none'; }, 3000); }toggleCoinInfo() { const coinInfo = document.getElementById('coinInfo'); if (coinInfo.style.display === 'none' || !coinInfo.style.display) { this.updateCoinList(); coinInfo.style.display = 'block'; } else { coinInfo.style.display = 'none'; } }updateCoinList() { const coinList = document.getElementById('coinList'); const collectedCoins = this.game.getCollectedCoins(); coinList.innerHTML = ''; collectedCoins.forEach(coin => { const entry = document.createElement('div'); entry.className = 'coin-entry'; entry.innerHTML = `
${coin.name}
Date: ${coin.date}
Mint: ${coin.mint}
Value: ${coin.value}
Context: ${coin.context}
`; coinList.appendChild(entry); });if (collectedCoins.length === 0) { coinList.innerHTML = '
No coins collected yet. Explore to find historical treasures!
'; } }animate() { requestAnimationFrame(() => this.animate()); const deltaTime = this.clock.getDelta(); // Update player controller const cameraRotation = this.cameraController.update(); this.playerController.update(deltaTime, cameraRotation); // Update game systems this.game.update(deltaTime); // Update UI document.getElementById('coinCounter').textContent = `Coins: ${this.game.collectedCoins.length}/${this.game.totalCoins}`; // Render this.renderer.render(this.scene, this.camera); }onWindowResize() { this.camera.aspect = window.innerWidth / window.innerHeight; this.camera.updateProjectionMatrix(); this.renderer.setSize(window.innerWidth, window.innerHeight); } }// Start the game new GameManager(); ]]>
{ this.createCoin(pos, `roman_${index}`); }); }checkCoinCollection(playerPosition) { this.coinObjects.forEach(coinObj => { if (!coinObj.userData.collected) { const distance = playerPosition.distanceTo(coinObj.position); if (distance < 1.5) { this.collectCoin(coinObj); } } }); }collectCoin(coinObject) { const coinId = coinObject.userData.coinId; const coinData = this.coinDatabase.getCoin(coinId); if (coinData) { this.collectedCoins.push(coinData); coinObject.userData.collected = true; // Animate coin collection const originalScale = coinObject.scale.clone(); const targetScale = new THREE.Vector3(2, 2, 2); const animateCollection = () => { coinObject.scale.lerp(targetScale, 0.1); coinObject.material?.opacity && (coinObject.material.opacity -= 0.05); if (coinObject.scale.x < 1.8) { requestAnimationFrame(animateCollection); } else { this.scene.remove(coinObject); } }; animateCollection(); // Show collection feedback this.showCoinCollectedFeedback(coinData); } }showCoinCollectedFeedback(coin) { const feedback = document.createElement('div'); feedback.style.cssText = ` position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background: rgba(0, 0, 0, 0.9); color: #ffd700; padding: 20px; border-radius: 10px; border: 2px solid #8b4513; font-size: 18px; font-weight: bold; text-align: center; z-index: 1000; animation: fadeInOut 2s ease-in-out forwards; `; feedback.innerHTML = `