diff --git a/index.html b/index.html
index 095f29a..b8c59c9 100644
--- a/index.html
+++ b/index.html
@@ -6,24 +6,6 @@
Horror Game
-
@@ -39,8 +21,7 @@
Battery: 100%
-
> Logger Initialized
+ style="position: absolute; top: 10px; left: 10px; z-index: 10000; color: lime; font-family: monospace; pointer-events: none; background: rgba(0,0,0,0.8); max-height: 50%; overflow-y: auto; font-size: 12px; padding: 10px; width: 300px; display: none;">
diff --git a/src/Graphics.js b/src/Graphics.js
index e73cab5..e1152a9 100644
--- a/src/Graphics.js
+++ b/src/Graphics.js
@@ -77,15 +77,6 @@ export class Graphics {
}
render() {
- if (!this.renderCount) this.renderCount = 0;
- this.renderCount++;
- if (this.renderCount % 500 === 0) window.log(`Frame: ${this.renderCount}`);
-
- // Diagnostic: Render 3D Scene directly to Screen
- this.renderer.setRenderTarget(null);
- this.renderer.render(this.scene, this.camera);
-
- /*
// 1. Render 3D Scene to RenderTarget
this.renderer.setRenderTarget(this.renderTarget);
this.renderer.render(this.scene, this.camera);
@@ -93,6 +84,5 @@ export class Graphics {
// 2. Render Post-Processing Quad to Screen
this.renderer.setRenderTarget(null);
this.renderer.render(this.postScene, this.postCamera);
- */
}
}
diff --git a/src/Player.js b/src/Player.js
index 7d6be2b..6ff698b 100644
--- a/src/Player.js
+++ b/src/Player.js
@@ -25,9 +25,14 @@ export class Player {
this.moveBackward = false;
this.moveLeft = false;
this.moveRight = false;
+ this.adjustDim = false; // 'K' key
+ this.adjustBright = false; // 'L' key
this.velocity = new THREE.Vector3();
this.direction = new THREE.Vector3();
+ this.direction = new THREE.Vector3();
this.flashlightOn = true; // Started as ON
+ this.battery = 100.0;
+ this.baseDrain = 0.5; // Drain per second at base intensity
this.setupInput();
this.setupFlashlight();
@@ -37,8 +42,8 @@ export class Player {
this.flashlight = new THREE.SpotLight(0xffffff, 10);
this.flashlight.angle = Math.PI / 6;
this.flashlight.penumbra = 0.3;
- this.flashlight.decay = 2;
- this.flashlight.distance = 15;
+ this.flashlight.decay = 1.5; // Lower decay for further reach
+ this.flashlight.distance = 60; // Significantly increased range
this.camera.add(this.flashlight);
this.flashlight.position.set(0, 0, 0);
@@ -54,6 +59,8 @@ export class Player {
case 'KeyS': this.moveBackward = true; break;
case 'KeyD': this.moveRight = true; break;
case 'KeyF': this.toggleFlashlight(); break;
+ case 'KeyK': this.adjustDim = true; break;
+ case 'KeyL': this.adjustBright = true; break;
}
};
@@ -63,6 +70,8 @@ export class Player {
case 'KeyA': this.moveLeft = false; break;
case 'KeyS': this.moveBackward = false; break;
case 'KeyD': this.moveRight = false; break;
+ case 'KeyK': this.adjustDim = false; break;
+ case 'KeyL': this.adjustBright = false; break;
}
};
@@ -76,6 +85,11 @@ export class Player {
// Better to allow F only when locked to avoid confusion.
if (!this.controls.isLocked) return;
+ if (this.battery <= 0 && this.flashlightOn === false) {
+ window.log('Cannot turn on: Battery empty');
+ return;
+ }
+
this.flashlightOn = !this.flashlightOn;
if (this.flashlight) {
this.flashlight.visible = this.flashlightOn;
@@ -147,9 +161,51 @@ export class Player {
// Keep player on ground
playerPos.y = this.height;
- // Flashlight flicker effect (subtle)
+ // Flashlight flicker effect (subtle) & Battery Logic
if (this.flashlight && this.flashlightOn) {
- this.flashlight.intensity = 10 + Math.random() * 0.5;
+ // Battery Drain
+ // Base intensity is ~10. Drain proportional to intensity.
+ const drainFactor = this.flashlight.intensity / 10.0;
+ const drain = this.baseDrain * drainFactor * dt;
+ this.battery = Math.max(0, this.battery - drain);
+
+ // Update UI
+ const battEl = document.getElementById('battery-level');
+ if (battEl) battEl.textContent = Math.floor(this.battery) + '%';
+ if (this.battery <= 20) {
+ if (battEl) battEl.style.color = 'red';
+ } else {
+ if (battEl) battEl.style.color = 'white';
+ }
+
+ // Die if empty
+ if (this.battery <= 0) {
+ this.flashlightOn = false;
+ this.flashlight.visible = false;
+ window.log('Battery depleted!');
+ }
+
+ // Handle manual adjustment
+ if (this.adjustDim || this.adjustBright) {
+ const speed = 2.0 * dt;
+ const angleSpeed = 0.5 * dt;
+
+ if (this.adjustDim) {
+ this.flashlight.intensity = Math.max(0, this.flashlight.intensity - speed * 10);
+ this.flashlight.angle = Math.max(0.1, this.flashlight.angle - angleSpeed);
+ }
+ if (this.adjustBright) {
+ this.flashlight.intensity = Math.min(50, this.flashlight.intensity + speed * 10);
+ this.flashlight.angle = Math.min(Math.PI / 2, this.flashlight.angle + angleSpeed);
+ }
+ // Log occasionally for feedback
+ if (Math.random() < 0.1) window.log(`Light: Int=${this.flashlight.intensity.toFixed(1)} Ang=${this.flashlight.angle.toFixed(2)}`);
+ } else {
+ // Only flicker if not adjusting? Or flicker on top of base intensity.
+ // Let's modify base intensity and add flicker
+ // Simplified: just flicker around the current value
+ this.flashlight.intensity += (Math.random() - 0.5) * 0.5;
+ }
}
}
}
diff --git a/src/World.js b/src/World.js
index b868341..01a858c 100644
--- a/src/World.js
+++ b/src/World.js
@@ -8,7 +8,7 @@ export class World {
load() {
// Standard lighting for horror
- const ambientLight = new THREE.AmbientLight(0x404040, 1.0); // Full brightness ambient for testing
+ const ambientLight = new THREE.AmbientLight(0x404040, 0.2); // Very dim ambient
this.scene.add(ambientLight);
// Floor
diff --git a/src/main.js b/src/main.js
index 183eff5..aa850f5 100644
--- a/src/main.js
+++ b/src/main.js
@@ -8,17 +8,8 @@ window.log = (msg) => {
logDiv.appendChild(span);
logDiv.scrollTop = logDiv.scrollHeight;
}
- console.log(msg);
};
-if (window.test2D) window.test2D();
-window.log(`Searching for WebGL...`);
-try {
- const canvas = document.createElement('canvas');
- const gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl');
- window.log(gl ? "WebGL Found" : "WebGL NOT Found");
-} catch (e) { window.log("WebGL Check Error: " + e.message); }
-
// Toggle debug log with 'P'
window.addEventListener('keydown', (e) => {
if (e.code === 'KeyP') {