Spaces:
Running
Running
Download index.html from SweatGuy12/a: direct link, hf CLI and curl.
- Browser
- Download file 60.9 kB
-
https://huggingface.co/spaces/SweatGuy12/a/resolve/main/index.html
- Command line
-
hf download hf://spaces/SweatGuy12/a/index.html
-
curl -L -o index.html https://huggingface.co/spaces/SweatGuy12/a/resolve/main/index.html
60.9 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TACTICAL BODYCAM: PITCH BLACK INVESTIGATION</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
user-select: none;
}
body, html {
width: 100%;
height: 100%;
overflow: hidden;
background-color: #010103;
font-family: 'Courier New', Courier, monospace;
}
#game-container {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
}
.bodycam-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
z-index: 10;
box-shadow: inset 0 0 160px rgba(0,0,0,0.98);
}
#nv-filter {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
z-index: 8;
background: rgba(0, 255, 60, 0.16);
mix-blend-mode: screen;
display: none;
box-shadow: inset 0 0 120px rgba(0,255,60,0.5);
}
#sniper-scope {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
z-index: 25;
display: none;
background: radial-gradient(circle, transparent 28%, rgba(0,0,0,0.94) 62%);
border: 2px solid rgba(0, 255, 204, 0.5);
}
.scope-crosshair-h {
position: absolute;
top: 50%;
left: 0;
width: 100%;
height: 1px;
background: rgba(0, 255, 204, 0.7);
}
.scope-crosshair-v {
position: absolute;
top: 0;
left: 50%;
width: 1px;
height: 100%;
background: rgba(0, 255, 204, 0.7);
}
.hud-top-left {
position: absolute;
top: 30px;
left: 40px;
color: #fff;
font-size: 20px;
font-weight: bold;
letter-spacing: 2px;
text-shadow: 0 0 6px rgba(255,255,255,0.8);
display: flex;
align-items: center;
gap: 15px;
}
.rec-dot {
width: 14px;
height: 14px;
background-color: #ff0000;
border-radius: 50%;
box-shadow: 0 0 12px #ff0000;
animation: blink 1s infinite;
}
@keyframes blink {
0% { opacity: 1; }
50% { opacity: 0.1; }
100% { opacity: 1; }
}
.hud-top-right {
position: absolute;
top: 30px;
right: 40px;
color: #00ffcc;
font-size: 18px;
text-align: right;
text-shadow: 0 0 6px rgba(0,255,204,0.6);
}
#radio-hud {
position: absolute;
top: 100px;
left: 40px;
background: rgba(10, 15, 25, 0.85);
border-left: 4px solid #00ffcc;
color: #00ffcc;
padding: 10px 18px;
font-size: 15px;
border-radius: 4px;
opacity: 0;
transition: opacity 0.4s ease;
box-shadow: 0 0 15px rgba(0,255,204,0.3);
max-width: 500px;
}
#interaction-prompt {
position: absolute;
top: 58%;
left: 50%;
transform: translate(-50%, -50%);
color: #ffaa00;
font-size: 16px;
font-weight: bold;
letter-spacing: 2px;
text-shadow: 0 0 8px rgba(255,170,0,0.8);
display: none;
z-index: 15;
background: rgba(0,0,0,0.75);
padding: 8px 16px;
border: 1px solid #ffaa00;
border-radius: 4px;
}
#world-markers {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
z-index: 9;
}
.waypoint {
position: absolute;
transform: translate(-50%, -50%);
padding: 4px 8px;
font-size: 12px;
font-weight: bold;
border-radius: 3px;
letter-spacing: 1px;
white-space: nowrap;
display: none;
box-shadow: 0 0 10px rgba(0,0,0,0.8);
}
.wp-enemy { background: rgba(180, 0, 0, 0.75); color: #fff; border: 1px solid #ff3333; }
.wp-civilian { background: rgba(0, 150, 255, 0.75); color: #fff; border: 1px solid #00ffff; }
.wp-item { background: rgba(200, 150, 0, 0.75); color: #fff; border: 1px solid #ffcc00; }
.hud-bottom {
position: absolute;
bottom: 30px;
left: 40px;
right: 40px;
display: flex;
justify-content: space-between;
align-items: flex-end;
color: #fff;
text-shadow: 0 0 5px rgba(0,0,0,0.9);
}
.stats-box {
background: rgba(10, 10, 15, 0.85);
border: 1px solid rgba(0, 255, 204, 0.4);
padding: 15px 25px;
backdrop-filter: blur(8px);
border-radius: 6px;
box-shadow: 0 0 20px rgba(0,0,0,0.6);
}
.stat-line {
font-size: 16px;
margin-bottom: 5px;
letter-spacing: 1px;
}
.heartrate-container {
width: 350px;
height: 80px;
background: rgba(10, 10, 15, 0.85);
border: 1px solid rgba(255, 0, 0, 0.5);
position: relative;
overflow: hidden;
border-radius: 6px;
box-shadow: 0 0 15px rgba(255,0,0,0.2);
}
#ecg-canvas {
width: 100%;
height: 100%;
}
.crosshair {
position: absolute;
top: 50%;
left: 50%;
width: 6px;
height: 6px;
background: rgba(255,255,255,0.7);
border-radius: 50%;
transform: translate(-50%, -50%);
pointer-events: none;
box-shadow: 0 0 4px #000;
}
#blood-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: radial-gradient(circle, rgba(140,0,0,0) 25%, rgba(120,0,0,0.95) 95%);
opacity: 0;
pointer-events: none;
transition: opacity 0.3s ease;
z-index: 5;
}
#instructions {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(2, 2, 4, 0.98);
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
z-index: 100;
color: #fff;
text-align: center;
padding: 20px;
}
#instructions h1 {
font-size: 38px;
color: #00ffcc;
margin-bottom: 15px;
letter-spacing: 3px;
text-shadow: 0 0 20px rgba(0,255,204,0.6);
}
#instructions p {
font-size: 15px;
color: #ccc;
max-width: 850px;
line-height: 1.6;
margin-bottom: 30px;
}
.btn-start {
background: #00ffcc;
color: #030305;
border: none;
padding: 15px 40px;
font-size: 18px;
font-weight: bold;
cursor: pointer;
letter-spacing: 2px;
transition: all 0.2s;
box-shadow: 0 0 25px rgba(0,255,204,0.5);
font-family: 'Courier New', Courier, monospace;
border-radius: 4px;
}
.btn-start:hover {
background: #33ffdd;
box-shadow: 0 0 35px rgba(51,255,221,0.8);
transform: scale(1.05);
}
.indicator-badge {
position: absolute;
top: 80px;
left: 40px;
color: #ffff00;
font-size: 14px;
letter-spacing: 1px;
display: none;
text-shadow: 0 0 5px rgba(255,255,0,0.8);
}
#nv-ind {
position: absolute;
top: 105px;
left: 40px;
color: #00ff44;
font-size: 14px;
letter-spacing: 1px;
display: none;
text-shadow: 0 0 8px rgba(0,255,68,0.8);
}
#laser-ind {
position: absolute;
top: 130px;
left: 40px;
color: #ff2222;
font-size: 14px;
letter-spacing: 1px;
display: none;
text-shadow: 0 0 8px rgba(255,34,34,0.8);
}
</style>
</head>
<body>
<div id="instructions">
<h1>TACTICAL BODYCAM: PITCH BLACK INVESTIGATION</h1>
<p>Houses are pitch black. You must toggle Night Vision [K] to search rooms, eliminate threats, protect civilians, and <strong>press [O] to arrest/detain civilians</strong>. Total 10 levels of intense clearance operations!</p>
<p style="color: #00ffcc; margin-bottom: 20px;">
[W, A, S, D] Move | [MOUSE] Look | [K] Toggle Night Vision | [1, 2, 3] Switch Weapon<br>
[LEFT CLICK] Shoot | [R] Reload | [G] Throw Grenade<br>
<strong style="color: #ffaa00;">[HOLD U] Breach House Doors</strong> | <strong style="color: #00ffff;">[O] Arrest Civilian</strong> | <strong style="color: #ff5555;">[M] Stand Still & Press to Take Medication</strong><br>
<strong style="color: #00ffcc;">[RIGHT CLICK TAP] Toggle Laser | [RIGHT CLICK HOLD] Sniper Scope</strong>
</p>
<button class="btn-start" id="start-btn">START OPERATION</button>
</div>
<div id="game-container"></div>
<div id="blood-overlay"></div>
<div id="nv-filter"></div>
<div id="sniper-scope">
<div class="scope-crosshair-h"></div>
<div class="scope-crosshair-v"></div>
</div>
<div id="interaction-prompt">PRESS [O] TO ARREST CIVILIAN</div>
<div class="bodycam-overlay">
<div class="hud-top-left">
<div class="rec-dot"></div>
<span>REC [ 4K / 60FPS - BODYCAM ]</span>
</div>
<div class="indicator-badge" id="cam-ind">SECURITY CAMERA ACTIVE [PRESS C TO EXIT]</div>
<div id="nv-ind">NIGHT VISION ACTIVE [GEN-3 NVG]</div>
<div id="laser-ind">TACTICAL LASER ACTIVE</div>
<div id="radio-hud">ALPHA-2: Rooms are pitch black. Use Night Vision [K] and arrest civilians with [O]!</div>
<div id="world-markers">
<div id="marker-enemy" class="waypoint wp-enemy">HOSTILE [0m]</div>
<div id="marker-civilian" class="waypoint wp-civilian">CIVILIAN [0m]</div>
<div id="marker-item" class="waypoint wp-item">KEYCARD [0m]</div>
</div>
<div class="hud-top-right" id="score-display">
CASH: $0<br>
LEVEL: 1/10 | ENEMIES: 0 | CIVILIANS: 0/0
</div>
<div class="crosshair"></div>
<div class="hud-bottom">
<div class="stats-box">
<div class="stat-line" id="hp-display">HP: 100 HP</div>
<div class="stat-line" id="ammo-display">AMMO: 30 / 90</div>
<div class="stat-line" id="weapon-display">WEAPON: M4A1-S TACTICAL</div>
</div>
<div class="heartrate-container">
<canvas id="ecg-canvas"></canvas>
</div>
</div>
</div>
<!-- Three.js CDN -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
<script>
let scene, camera, renderer;
let player = {
x: 0, z: 68, rotY: 0, rotX: 0,
targetRotY: 0, targetRotX: 0,
hp: 100, money: 0, keycards: 0, isDead: false
};
const weapons = [
{ name: "M4A1-S TACTICAL", ammo: 30, reserve: 90, damage: 50, color: 0x1f242d },
{ name: "AK-47 ELITE", ammo: 30, reserve: 90, damage: 70, color: 0x5c4033 },
{ name: "AWP SNIPER", ammo: 10, reserve: 30, damage: 100, color: 0x113322 }
];
let currentWeaponIndex = 0;
let currentLevel = 1;
const maxLevel = 10;
let keys = { w: false, a: false, s: false, d: false, u: false };
let isPointerLocked = false;
let enemies = [];
let civilians = [];
let grenades = [];
let bloodDecals = [];
let keycards = [];
let doors = [];
let securityCameras = [];
let currentCamIndex = -1;
let nightVisionActive = false;
let laserActive = false;
let sniperZoomActive = false;
let laserMesh = null;
let audioCtx = null;
let walls = [];
let weaponModelGroup;
let uKeyHoldTime = 0;
let targetDoorToBreach = null;
let targetCivilianToArrest = null;
const mapSize = 160;
const instructionsEl = document.getElementById('instructions');
const startBtn = document.getElementById('start-btn');
const hpDisplay = document.getElementById('hp-display');
const ammoDisplay = document.getElementById('ammo-display');
const scoreDisplay = document.getElementById('score-display');
const weaponDisplay = document.getElementById('weapon-display');
const bloodOverlay = document.getElementById('blood-overlay');
const camInd = document.getElementById('cam-ind');
const nvInd = document.getElementById('nv-ind');
const laserInd = document.getElementById('laser-ind');
const nvFilter = document.getElementById('nv-filter');
const sniperScope = document.getElementById('sniper-scope');
const radioHud = document.getElementById('radio-hud');
const interactionPrompt = document.getElementById('interaction-prompt');
const markerEnemy = document.getElementById('marker-enemy');
const markerCivilian = document.getElementById('marker-civilian');
const markerItem = document.getElementById('marker-item');
const ecgCanvas = document.getElementById('ecg-canvas');
const ecgCtx = ecgCanvas.getContext('2d');
ecgCanvas.width = 350;
ecgCanvas.height = 80;
let ecgOffset = 0;
let heartRate = 78;
let lastHeartbeatTime = 0;
const radioDialogues = [
"Alpha-2: Rooms are pitch black. Turn on Night Vision with [K].",
"Alpha-2: Inspect rooms carefully. Protect and arrest civilians with [O].",
"Alpha-2: Check corners for hostiles. Neutralize threats immediately.",
"Alpha-2: Heart rate spiking! Take medication with [M] while standing still."
];
window.addEventListener('contextmenu', e => e.preventDefault());
startBtn.addEventListener('click', () => {
instructionsEl.style.display = 'none';
document.body.requestPointerLock();
initAudio();
initGame();
animate();
startRadioChatter();
});
document.addEventListener('pointerlockchange', () => {
isPointerLocked = document.pointerLockElement === document.body;
});
window.addEventListener('resize', () => {
if (camera && renderer) {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
}
});
function initAudio() {
if (!audioCtx) audioCtx = new (window.AudioContext || window.webkitAudioContext)();
}
function playGunshotSound() {
if (!audioCtx) return;
let osc = audioCtx.createOscillator();
let gain = audioCtx.createGain();
osc.type = currentWeaponIndex === 2 ? 'square' : 'sawtooth';
osc.frequency.setValueAtTime(currentWeaponIndex === 2 ? 70 : 160, audioCtx.currentTime);
osc.frequency.exponentialRampToValueAtTime(10, audioCtx.currentTime + 0.35);
gain.gain.setValueAtTime(0.7, audioCtx.currentTime);
gain.gain.linearRampToValueAtTime(0.01, audioCtx.currentTime + 0.35);
osc.connect(gain);
gain.connect(audioCtx.destination);
osc.start();
osc.stop(audioCtx.currentTime + 0.35);
}
function playReloadSound() {
if (!audioCtx) return;
let osc = audioCtx.createOscillator();
let gain = audioCtx.createGain();
osc.type = 'triangle';
osc.frequency.setValueAtTime(320, audioCtx.currentTime);
osc.frequency.setValueAtTime(520, audioCtx.currentTime + 0.15);
gain.gain.setValueAtTime(0.25, audioCtx.currentTime);
gain.gain.linearRampToValueAtTime(0.01, audioCtx.currentTime + 0.35);
osc.connect(gain);
gain.connect(audioCtx.destination);
osc.start();
osc.stop(audioCtx.currentTime + 0.35);
}
function playNVSound() {
if (!audioCtx) return;
let osc = audioCtx.createOscillator();
let gain = audioCtx.createGain();
osc.type = 'sine';
osc.frequency.setValueAtTime(1200, audioCtx.currentTime);
osc.frequency.exponentialRampToValueAtTime(400, audioCtx.currentTime + 0.2);
gain.gain.setValueAtTime(0.3, audioCtx.currentTime);
gain.gain.linearRampToValueAtTime(0.01, audioCtx.currentTime + 0.2);
osc.connect(gain);
gain.connect(audioCtx.destination);
osc.start();
osc.stop(audioCtx.currentTime + 0.2);
}
function playHeartbeatThump() {
if (!audioCtx) return;
let osc = audioCtx.createOscillator();
let gain = audioCtx.createGain();
osc.type = 'sine';
osc.frequency.setValueAtTime(90, audioCtx.currentTime);
osc.frequency.exponentialRampToValueAtTime(30, audioCtx.currentTime + 0.12);
gain.gain.setValueAtTime(0.55, audioCtx.currentTime);
gain.gain.linearRampToValueAtTime(0.01, audioCtx.currentTime + 0.15);
osc.connect(gain);
gain.connect(audioCtx.destination);
osc.start();
osc.stop(audioCtx.currentTime + 0.15);
}
function playArrestSound() {
if (!audioCtx) return;
let osc = audioCtx.createOscillator();
let gain = audioCtx.createGain();
osc.type = 'sine';
osc.frequency.setValueAtTime(500, audioCtx.currentTime);
osc.frequency.setValueAtTime(900, audioCtx.currentTime + 0.1);
gain.gain.setValueAtTime(0.4, audioCtx.currentTime);
gain.gain.linearRampToValueAtTime(0.01, audioCtx.currentTime + 0.3);
osc.connect(gain);
gain.connect(audioCtx.destination);
osc.start();
osc.stop(audioCtx.currentTime + 0.3);
}
function playPillSound() {
if (!audioCtx) return;
let osc = audioCtx.createOscillator();
let gain = audioCtx.createGain();
osc.type = 'sine';
osc.frequency.setValueAtTime(400, audioCtx.currentTime);
osc.frequency.exponentialRampToValueAtTime(800, audioCtx.currentTime + 0.3);
gain.gain.setValueAtTime(0.4, audioCtx.currentTime);
gain.gain.linearRampToValueAtTime(0.01, audioCtx.currentTime + 0.3);
osc.connect(gain);
gain.connect(audioCtx.destination);
osc.start();
osc.stop(audioCtx.currentTime + 0.3);
}
function playBreachSound() {
if (!audioCtx) return;
let osc = audioCtx.createOscillator();
let gain = audioCtx.createGain();
osc.type = 'sawtooth';
osc.frequency.setValueAtTime(180, audioCtx.currentTime);
osc.frequency.exponentialRampToValueAtTime(40, audioCtx.currentTime + 0.4);
gain.gain.setValueAtTime(0.8, audioCtx.currentTime);
gain.gain.linearRampToValueAtTime(0.01, audioCtx.currentTime + 0.4);
osc.connect(gain);
gain.connect(audioCtx.destination);
osc.start();
osc.stop(audioCtx.currentTime + 0.4);
}
function playExplosionSound() {
if (!audioCtx) return;
let osc = audioCtx.createOscillator();
let gain = audioCtx.createGain();
osc.type = 'sawtooth';
osc.frequency.setValueAtTime(120, audioCtx.currentTime);
osc.frequency.exponentialRampToValueAtTime(20, audioCtx.currentTime + 0.6);
gain.gain.setValueAtTime(0.9, audioCtx.currentTime);
gain.gain.linearRampToValueAtTime(0.01, audioCtx.currentTime + 0.6);
osc.connect(gain);
gain.connect(audioCtx.destination);
osc.start();
osc.stop(audioCtx.currentTime + 0.6);
}
function playFlatlineSound() {
if (!audioCtx) return;
let osc = audioCtx.createOscillator();
let gain = audioCtx.createGain();
osc.type = 'sine';
osc.frequency.setValueAtTime(800, audioCtx.currentTime);
gain.gain.setValueAtTime(0.4, audioCtx.currentTime);
gain.gain.linearRampToValueAtTime(0.01, audioCtx.currentTime + 2.5);
osc.connect(gain);
gain.connect(audioCtx.destination);
osc.start();
osc.stop(audioCtx.currentTime + 2.5);
}
function speakRadio(text) {
if ('speechSynthesis' in window) {
let utterance = new SpeechSynthesisUtterance(text);
utterance.lang = 'en-US';
utterance.pitch = 0.70;
utterance.rate = 1.05;
window.speechSynthesis.speak(utterance);
}
radioHud.innerText = text;
radioHud.style.opacity = '1';
setTimeout(() => { radioHud.style.opacity = '0'; }, 4500);
}
function startRadioChatter() {
setInterval(() => {
if (!player.isDead && isPointerLocked && currentCamIndex === -1) {
let msg = radioDialogues[Math.floor(Math.random() * radioDialogues.length)];
if (heartRate > 130 && Math.random() > 0.4) {
msg = "Alpha-2: Critical heart rate! Stand still and press [M] for medication!";
}
speakRadio(msg);
}
}, 18000);
}
function createProceduralTexture(type) {
const canvas = document.createElement('canvas');
canvas.width = 512;
canvas.height = 512;
const ctx = canvas.getContext('2d');
if (type === 'concrete') {
ctx.fillStyle = '#05070a';
ctx.fillRect(0, 0, 512, 512);
ctx.strokeStyle = '#0a0e14';
ctx.lineWidth = 6;
ctx.strokeRect(0, 0, 512, 512);
for (let i = 0; i < 3500; i++) {
ctx.fillStyle = Math.random() > 0.5 ? '#0c1018' : '#020305';
ctx.fillRect(Math.random()*512, Math.random()*512, 4, 4);
}
} else if (type === 'brick') {
ctx.fillStyle = '#0f0e0d';
ctx.fillRect(0, 0, 512, 512);
ctx.strokeStyle = '#050404';
ctx.lineWidth = 4;
for (let y = 0; y < 512; y += 32) {
ctx.beginPath();
ctx.moveTo(0, y);
ctx.lineTo(512, y);
ctx.stroke();
let offset = (y / 32) % 2 === 0 ? 0 : 32;
for (let x = offset; x < 512; x += 64) {
ctx.strokeRect(x, y, 64, 32);
}
}
}
return new THREE.CanvasTexture(canvas);
}
function initGame() {
scene = new THREE.Scene();
scene.background = new THREE.Color(0x000000);
scene.fog = new THREE.FogExp2(0x000000, 0.035);
camera = new THREE.PerspectiveCamera(70, window.innerWidth / window.innerHeight, 0.1, 1000);
camera.rotation.order = 'YXZ';
renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
document.getElementById('game-container').appendChild(renderer.domElement);
// Pitch black ambient light
const ambientLight = new THREE.AmbientLight(0x020204, 0.15);
scene.add(ambientLight);
const dirLight = new THREE.DirectionalLight(0x112233, 0.3);
dirLight.position.set(70, 100, 70);
dirLight.castShadow = true;
scene.add(dirLight);
const concreteTex = createProceduralTexture('concrete');
concreteTex.wrapS = THREE.RepeatWrapping;
concreteTex.wrapT = THREE.RepeatWrapping;
concreteTex.repeat.set(16, 16);
const floorGeo = new THREE.PlaneGeometry(mapSize, mapSize);
const floorMat = new THREE.MeshStandardMaterial({ map: concreteTex, roughness: 0.8 });
const floor = new THREE.Mesh(floorGeo, floorMat);
floor.rotation.x = -Math.PI / 2;
floor.receiveShadow = true;
scene.add(floor);
const ceiling = new THREE.Mesh(floorGeo, new THREE.MeshStandardMaterial({ color: 0x010102 }));
ceiling.position.y = 14;
ceiling.rotation.x = Math.PI / 2;
scene.add(ceiling);
createMapAssets();
setupSecurityCameras();
spawnKeycards(1);
spawnEnemies(5 + currentLevel * 2);
spawnCivilians(2 + Math.floor(currentLevel / 2));
updateWeaponModel();
window.addEventListener('keydown', onKeyDown);
window.addEventListener('keyup', onKeyUp);
window.addEventListener('mousemove', onMouseMove);
window.addEventListener('mousedown', onMouseDown);
window.addEventListener('mouseup', onMouseUp);
updateHUD();
}
function createMapAssets() {
const brickTex = createProceduralTexture('brick');
const houseMat = new THREE.MeshStandardMaterial({ map: brickTex, roughness: 0.6 });
const darkInteriorMat = new THREE.MeshStandardMaterial({ color: 0x020204, roughness: 0.9 });
const doorMat = new THREE.MeshStandardMaterial({ color: 0x1b130e, metalness: 0.3 });
const woodMat = new THREE.MeshStandardMaterial({ color: 0x18100a, roughness: 0.8 });
const trashMat = new THREE.MeshStandardMaterial({ color: 0x111116, roughness: 0.9 });
createWall(0, 7, -mapSize/2, mapSize, 14, 3, houseMat);
createWall(0, 7, mapSize/2, mapSize, 14, 3, houseMat);
createWall(-mapSize/2, 7, 0, 3, 14, mapSize, houseMat);
createWall(mapSize/2, 7, 0, 3, 14, mapSize, houseMat);
// 4 Pitch Dark Messy Safehouses
buildMessyHouse(-38, -38, houseMat, darkInteriorMat, doorMat, woodMat, trashMat);
buildMessyHouse(38, -38, houseMat, darkInteriorMat, doorMat, woodMat, trashMat);
buildMessyHouse(-38, 38, houseMat, darkInteriorMat, doorMat, woodMat, trashMat);
buildMessyHouse(38, 38, houseMat, darkInteriorMat, doorMat, woodMat, trashMat);
}
function buildMessyHouse(cx, cz, wallMat, interiorMat, doorMat, woodMat, trashMat) {
let width = 32, depth = 32, floorHeight = 6;
createWall(cx - width/2, floorHeight, cz, 2, floorHeight*2, depth, wallMat);
createWall(cx + width/2, floorHeight, cz, 2, floorHeight*2, depth, wallMat);
createWall(cx, floorHeight, cz - depth/2, width, floorHeight*2, 2, wallMat);
createWall(cx, floorHeight, cz + depth/2, width, floorHeight*2, 2, wallMat);
const ceilingGeo = new THREE.BoxGeometry(width, 0.5, depth);
const ceilingMesh = new THREE.Mesh(ceilingGeo, interiorMat);
ceilingMesh.position.set(cx, floorHeight, cz);
ceilingMesh.receiveShadow = true;
ceilingMesh.castShadow = true;
scene.add(ceilingMesh);
walls.push({ x: cx, z: cz, w: width, d: depth });
// Internal partitions
createWall(cx - 5, floorHeight/2, cz - 3, 1, floorHeight, 16, interiorMat);
createWall(cx + 6, floorHeight/2, cz + 4, 14, floorHeight, 1, interiorMat);
createWall(cx - 2, floorHeight/2, cz + 8, 1, floorHeight, 12, interiorMat);
let y2 = floorHeight + floorHeight/2;
createWall(cx, y2, cz, 1.2, floorHeight, depth - 4, interiorMat);
createWall(cx, y2, cz, width - 4, floorHeight, 1.2, interiorMat);
// Clutter / Mess inside
for (let i = 0; i < 6; i++) {
let rx = cx + (Math.random() - 0.5) * 22;
let rz = cz + (Math.random() - 0.5) * 22;
let isTable = Math.random() > 0.5;
let objGeo = isTable ? new THREE.BoxGeometry(3.2, 1.2, 1.8) : new THREE.BoxGeometry(1.2, 1.2, 1.2);
let objMesh = new THREE.Mesh(objGeo, isTable ? woodMat : trashMat);
objMesh.position.set(rx, 0.6, rz);
objMesh.rotation.x = (Math.random() - 0.5) * 0.8;
objMesh.rotation.z = (Math.random() - 0.5) * 0.8;
objMesh.rotation.y = Math.random() * Math.PI;
objMesh.castShadow = true;
scene.add(objMesh);
}
const doorGeo = new THREE.BoxGeometry(3, 5, 0.6);
let doorMesh = new THREE.Mesh(doorGeo, doorMat);
doorMesh.position.set(cx, 3, cz + depth/2 - 1);
scene.add(doorMesh);
doors.push({
mesh: doorMesh,
x: cx,
z: cz + depth/2 - 1,
isLocked: true,
isBreached: false
});
}
function createWall(x, y, z, w, h, d, mat) {
const geo = new THREE.BoxGeometry(w, h, d);
const mesh = new THREE.Mesh(geo, mat);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
scene.add(mesh);
walls.push({ x, z, w, d });
}
function setupSecurityCameras() {
const camPositions = [
{ x: -65, y: 11, z: -65, rotY: Math.PI / 4 },
{ x: 65, y: 11, z: -65, rotY: -Math.PI / 4 },
{ x: -65, y: 11, z: 65, rotY: 3 * Math.PI / 4 },
{ x: 65, y: 11, z: 65, rotY: -3 * Math.PI / 4 }
];
camPositions.forEach((pos) => {
const camObj = new THREE.PerspectiveCamera(65, window.innerWidth / window.innerHeight, 0.1, 200);
camObj.position.set(pos.x, pos.y, pos.z);
camObj.rotation.y = pos.rotY;
scene.add(camObj);
securityCameras.push(camObj);
const mountGeo = new THREE.BoxGeometry(1, 1, 2);
const mountMat = new THREE.MeshStandardMaterial({ color: 0x111111 });
const mesh = new THREE.Mesh(mountGeo, mountMat);
mesh.position.set(pos.x, pos.y, pos.z);
mesh.rotation.y = pos.rotY;
scene.add(mesh);
});
}
function spawnKeycards(count) {
for (let i = 0; i < count; i++) {
const geo = new THREE.BoxGeometry(1.2, 0.1, 0.8);
const mat = new THREE.MeshStandardMaterial({ color: 0xffaa00, emissive: 0xffaa00, emissiveIntensity: 0.6 });
const mesh = new THREE.Mesh(geo, mat);
let kx = (Math.random() - 0.5) * 100;
let kz = (Math.random() - 0.5) * 100;
mesh.position.set(kx, 0.2, kz);
scene.add(mesh);
keycards.push({ mesh: mesh, collected: false });
}
}
function spawnEnemies(count) {
for (let i = 0; i < count; i++) {
const group = new THREE.Group();
const bodyGeo = new THREE.BoxGeometry(1.3, 2.1, 0.9);
const bodyMat = new THREE.MeshStandardMaterial({ color: 0x3d0f0f, roughness: 0.5 });
const body = new THREE.Mesh(bodyGeo, bodyMat);
body.position.y = 1.05;
body.castShadow = true;
group.add(body);
const headGeo = new THREE.BoxGeometry(0.7, 0.7, 0.7);
const headMat = new THREE.MeshStandardMaterial({ color: 0xc49a6c });
const head = new THREE.Mesh(headGeo, headMat);
head.position.y = 2.45;
group.add(head);
let rx, rz;
do {
rx = (Math.random() - 0.5) * 120;
rz = (Math.random() - 0.5) * 120;
} while (Math.abs(rx) < 25 && Math.abs(rz) < 25);
group.position.set(rx, 0, rz);
scene.add(group);
enemies.push({
mesh: group,
hp: 100,
speed: 0.024 + Math.random() * 0.015
});
}
}
function spawnCivilians(count) {
for (let i = 0; i < count; i++) {
const group = new THREE.Group();
const bodyGeo = new THREE.BoxGeometry(1.2, 2.0, 0.85);
const bodyMat = new THREE.MeshStandardMaterial({ color: 0x1034a6, roughness: 0.5 });
const body = new THREE.Mesh(bodyGeo, bodyMat);
body.position.y = 1.0;
body.castShadow = true;
group.add(body);
const headGeo = new THREE.BoxGeometry(0.68, 0.68, 0.68);
const headMat = new THREE.MeshStandardMaterial({ color: 0xd6a87b });
const head = new THREE.Mesh(headGeo, headMat);
head.position.y = 2.38;
group.add(head);
let rx = (Math.random() - 0.5) * 110;
let rz = (Math.random() - 0.5) * 110;
group.position.set(rx, 0, rz);
scene.add(group);
civilians.push({
mesh: group,
arrested: false
});
}
}
function updateWeaponModel() {
if (weaponModelGroup) camera.remove(weaponModelGroup);
weaponModelGroup = new THREE.Group();
let wInfo = weapons[currentWeaponIndex];
const bodyGeo = new THREE.BoxGeometry(0.16, 0.22, 1.1);
const bodyMat = new THREE.MeshStandardMaterial({ color: wInfo.color, metalness: 0.85, roughness: 0.2 });
const body = new THREE.Mesh(bodyGeo, bodyMat);
weaponModelGroup.add(body);
const barrelGeo = new THREE.CylinderGeometry(0.05, 0.05, 0.6, 12);
const barrelMat = new THREE.MeshStandardMaterial({ color: 0x111111, metalness: 0.9, roughness: 0.1 });
const barrel = new THREE.Mesh(barrelGeo, barrelMat);
barrel.rotation.x = Math.PI / 2;
barrel.position.set(0, 0.02, -0.8);
weaponModelGroup.add(barrel);
if (currentWeaponIndex === 2) {
const scopeGeo = new THREE.CylinderGeometry(0.08, 0.08, 0.4, 12);
const scope = new THREE.Mesh(scopeGeo, barrelMat);
scope.rotation.x = Math.PI / 2;
scope.position.set(0, 0.18, -0.1);
weaponModelGroup.add(scope);
} else {
const magGeo = new THREE.BoxGeometry(0.12, 0.35, 0.2);
const mag = new THREE.Mesh(magGeo, barrelMat);
mag.position.set(0, -0.22, 0.1);
weaponModelGroup.add(mag);
const laserGeo = new THREE.CylinderGeometry(0.02, 0.02, 0.3, 8);
const laserMat = new THREE.MeshBasicMaterial({ color: 0xff0000 });
laserMesh = new THREE.Mesh(laserGeo, laserMat);
laserMesh.rotation.x = Math.PI / 2;
laserMesh.position.set(0.08, -0.05, -0.5);
laserMesh.visible = laserActive && currentWeaponIndex !== 2;
weaponModelGroup.add(laserMesh);
}
weaponModelGroup.position.set(0.38, -0.32, -0.65);
camera.add(weaponModelGroup);
scene.add(camera);
}
function updateLaserVisibility() {
if (laserMesh && currentWeaponIndex !== 2) {
laserMesh.visible = laserActive;
}
laserInd.style.display = (laserActive && currentWeaponIndex !== 2) ? 'block' : 'none';
}
function onKeyDown(e) {
if (player.isDead) return;
const code = e.code;
const key = e.key.toLowerCase();
if (code === 'KeyW' || key === 'w') keys.w = true;
if (code === 'KeyS' || key === 's') keys.s = true;
if (code === 'KeyA' || key === 'a') keys.a = true;
if (code === 'KeyD' || key === 'd') keys.d = true;
if (code === 'KeyU' || key === 'u') keys.u = true;
if (code === 'KeyR' || key === 'r') reloadWeapon();
if (code === 'KeyG' || key === 'g') throwGrenade();
if (code === 'KeyF' || key === 'f') toggleSecurityCamera();
if (code === 'KeyC' || key === 'c') exitSecurityCamera();
if (code === 'KeyK' || key === 'k') toggleNightVision();
if (code === 'KeyO' || key === 'o') arrestCivilian();
if (code === 'KeyM' || key === 'm') {
let isMoving = keys.w || keys.a || keys.s || keys.d;
if (!isMoving && heartRate > 85) {
heartRate = Math.max(70, heartRate - 50);
bloodOverlay.style.opacity = Math.max(0, parseFloat(bloodOverlay.style.opacity || 0) - 0.5);
playPillSound();
speakRadio("Alpha-2: Medication administered. Heart rate stabilizing.");
} else if (isMoving) {
speakRadio("Alpha-2: Stop moving before taking medication!");
}
}
if (key === '1') switchWeapon(0);
if (key === '2') switchWeapon(1);
if (key === '3') switchWeapon(2);
}
function onKeyUp(e) {
const code = e.code;
const key = e.key.toLowerCase();
if (code === 'KeyW' || key === 'w') keys.w = false;
if (code === 'KeyS' || key === 's') keys.s = false;
if (code === 'KeyA' || key === 'a') keys.a = false;
if (code === 'KeyD' || key === 'd') keys.d = false;
if (code === 'KeyU' || key === 'u') {
keys.u = false;
uKeyHoldTime = 0;
interactionPrompt.style.display = 'none';
}
}
function onMouseMove(e) {
if (!isPointerLocked || player.isDead || currentCamIndex !== -1) return;
let sensitivity = sniperZoomActive ? 0.0008 : 0.0022;
player.targetRotY -= e.movementX * sensitivity;
player.targetRotX -= e.movementY * sensitivity;
player.targetRotX = Math.max(-Math.PI / 2.3, Math.min(Math.PI / 2.3, player.targetRotX));
}
function switchWeapon(index) {
currentWeaponIndex = index;
if (currentWeaponIndex === 2) laserActive = false;
updateWeaponModel();
updateLaserVisibility();
updateHUD();
}
function onMouseDown(e) {
if (!isPointerLocked || player.isDead || currentCamIndex !== -1) return;
if (e.button === 0) {
shootWeapon();
} else if (e.button === 2) {
if (currentWeaponIndex === 2) {
sniperZoomActive = true;
camera.fov = 20;
camera.updateProjectionMatrix();
sniperScope.style.display = 'block';
playNVSound();
} else {
laserActive = !laserActive;
playPillSound();
speakRadio(laserActive ? "Alpha-2: Tactical laser activated." : "Alpha-2: Tactical laser deactivated.");
updateLaserVisibility();
}
}
}
function onMouseUp(e) {
if (e.button === 2 && currentWeaponIndex === 2 && sniperZoomActive) {
sniperZoomActive = false;
camera.fov = 70;
camera.updateProjectionMatrix();
sniperScope.style.display = 'none';
}
}
function exitSecurityCamera() {
if (currentCamIndex !== -1) {
currentCamIndex = -1;
camInd.style.display = 'none';
}
}
function toggleSecurityCamera() {
currentCamIndex++;
if (currentCamIndex >= securityCameras.length) {
currentCamIndex = -1;
camInd.style.display = 'none';
} else {
camInd.style.display = 'block';
}
}
function toggleNightVision() {
nightVisionActive = !nightVisionActive;
playNVSound();
if (nightVisionActive) {
scene.background = new THREE.Color(0x001100);
scene.fog.color = new THREE.Color(0x001100);
nvFilter.style.display = 'block';
nvInd.style.display = 'block';
speakRadio("Alpha-2: Night vision engaged.");
} else {
scene.background = new THREE.Color(0x000000);
scene.fog.color = new THREE.Color(0x000000);
nvFilter.style.display = 'none';
nvInd.style.display = 'none';
speakRadio("Alpha-2: Night vision disengaged.");
}
}
function arrestCivilian() {
if (targetCivilianToArrest && !targetCivilianToArrest.arrested) {
targetCivilianToArrest.arrested = true;
scene.remove(targetCivilianToArrest.mesh);
player.money += 300;
playArrestSound();
speakRadio("Alpha-2: Civilian secured and arrested safely!");
updateHUD();
checkLevelCompletion();
}
}
function shootWeapon() {
let wInfo = weapons[currentWeaponIndex];
if (wInfo.ammo <= 0) {
playReloadSound();
return;
}
wInfo.ammo--;
playGunshotSound();
updateHUD();
const raycaster = new THREE.Raycaster();
raycaster.setFromCamera(new THREE.Vector2(0, 0), camera);
let enemyMeshes = enemies.map(e => e.mesh);
let intersects = raycaster.intersectObjects(enemyMeshes, true);
if (intersects.length > 0) {
let hitMesh = intersects[0].object;
let targetEnemy = enemies.find(e => e.mesh === hitMesh.parent || e.mesh === hitMesh.parent?.parent);
if (targetEnemy) {
spawnBloodSplatter(intersects[0].point);
heartRate = Math.min(190, heartRate + 18);
targetEnemy.hp -= wInfo.damage;
if (targetEnemy.hp <= 0) {
spawnBloodPool(targetEnemy.mesh.position);
scene.remove(targetEnemy.mesh);
enemies = enemies.filter(e => e !== targetEnemy);
player.money += 400;
updateHUD();
checkLevelCompletion();
}
}
}
}
function spawnBloodSplatter(pos) {
const geo = new THREE.CircleGeometry(0.35, 8);
const mat = new THREE.MeshBasicMaterial({ color: 0x880000, transparent: true, opacity: 0.85 });
const mesh = new THREE.Mesh(geo, mat);
mesh.position.copy(pos);
mesh.rotation.x = -Math.PI / 2;
scene.add(mesh);
bloodDecals.push(mesh);
}
function spawnBloodPool(pos) {
const geo = new THREE.CircleGeometry(2.2, 16);
const mat = new THREE.MeshBasicMaterial({ color: 0x550000, transparent: true, opacity: 0.9 });
const mesh = new THREE.Mesh(geo, mat);
mesh.position.set(pos.x, 0.03, pos.z);
mesh.rotation.x = -Math.PI / 2;
scene.add(mesh);
bloodDecals.push(mesh);
}
function checkLevelCompletion() {
let activeCivilians = civilians.filter(c => !c.arrested).length;
if (enemies.length === 0 && activeCivilians === 0) {
advanceLevel();
}
}
function advanceLevel() {
currentLevel++;
if (currentLevel > maxLevel) {
speakRadio("Alpha-2: All 10 sectors successfully cleared! Victory!");
instructionsEl.style.display = 'flex';
instructionsEl.querySelector('h1').innerText = "CAMPAIGN COMPLETED [VICTORY]";
instructionsEl.querySelector('p').innerText = "You have successfully cleared all 10 pitch black sectors.";
startBtn.style.display = 'none';
document.exitPointerLock();
return;
}
speakRadio(`Alpha-2: Sector ${currentLevel - 1} cleared! Advancing to Sector ${currentLevel} of 10!`);
bloodOverlay.style.background = 'radial-gradient(circle, rgba(0,255,200,0.2) 20%, rgba(0,0,0,0.98) 95%)';
bloodOverlay.style.opacity = '1';
setTimeout(() => {
player.x = (Math.random() - 0.5) * 20;
player.z = (Math.random() - 0.5) * 20;
spawnKeycards(1);
spawnEnemies(5 + currentLevel * 2);
spawnCivilians(2 + Math.floor(currentLevel / 2));
bloodOverlay.style.background = 'radial-gradient(circle, rgba(140,0,0,0) 25%, rgba(120,0,0,0.95) 95%)';
bloodOverlay.style.opacity = '0';
updateHUD();
speakRadio(`Alpha-2: Sector ${currentLevel} active. Engage night vision and clear rooms!`);
}, 1800);
}
function reloadWeapon() {
let wInfo = weapons[currentWeaponIndex];
let maxAmmo = currentWeaponIndex === 2 ? 10 : 30;
if (wInfo.reserve <= 0 || wInfo.ammo === maxAmmo) return;
playReloadSound();
let needed = maxAmmo - wInfo.ammo;
let take = Math.min(needed, wInfo.reserve);
wInfo.ammo += take;
wInfo.reserve -= take;
updateHUD();
}
function throwGrenade() {
const geo = new THREE.SphereGeometry(0.35, 16, 16);
const mat = new THREE.MeshStandardMaterial({ color: 0x222222, metalness: 0.8 });
const mesh = new THREE.Mesh(geo, mat);
let camDir = new THREE.Vector3();
camera.getWorldDirection(camDir);
let startPos = new THREE.Vector3(player.x, 2.0, player.z);
mesh.position.copy(startPos);
scene.add(mesh);
let velocity = camDir.clone().multiplyScalar(0.55).add(new THREE.Vector3(0, 0.32, 0));
grenades.push({
mesh: mesh,
pos: startPos,
velocity: velocity,
life: 90
});
speakRadio("Alpha-2: Grenade deployed!");
}
function takeDamage(amount) {
if (player.isDead) return;
player.hp -= amount;
heartRate = Math.min(198, heartRate + 35);
let missingHpRatio = (100 - player.hp) / 100;
bloodOverlay.style.opacity = Math.min(0.95, 0.3 + missingHpRatio * 0.7);
setTimeout(() => {
if(!player.isDead) bloodOverlay.style.opacity = Math.max(0.15, missingHpRatio * 0.6);
}, 400);
if (player.hp <= 0) {
player.hp = 0;
player.isDead = true;
bloodOverlay.style.opacity = '1';
playFlatlineSound();
instructionsEl.style.display = 'flex';
instructionsEl.querySelector('h1').innerText = "OPERATION FAILED [KIA]";
instructionsEl.querySelector('p').innerText = "Refresh the page to retry.";
startBtn.style.display = 'none';
document.exitPointerLock();
}
updateHUD();
}
function updateHUD() {
hpDisplay.innerText = `HP: ${player.hp} HP`;
let wInfo = weapons[currentWeaponIndex];
ammoDisplay.innerText = `AMMO: ${wInfo.ammo} / ${wInfo.reserve}`;
weaponDisplay.innerText = `WEAPON: ${wInfo.name}`;
let arrestedCount = civilians.filter(c => c.arrested).length;
let totalCivilians = civilians.length + arrestedCount;
scoreDisplay.innerHTML = `CASH: $${player.money}<br>LEVEL: ${currentLevel}/10 | ENEMIES: ${enemies.length} | CIVILIANS: ${arrestedCount}/${totalCivilians}`;
}
function updateWaypoints() {
const playerPos = new THREE.Vector3(player.x, 2.2, player.z);
let activeItem = keycards.find(k => !k.collected);
if (activeItem) {
let dItem = Math.round(playerPos.distanceTo(activeItem.mesh.position));
markerItem.innerText = `KEYCARD [${dItem}m]`;
updateWaypointPosition(activeItem.mesh.position, markerItem);
markerItem.style.display = 'block';
} else {
markerItem.style.display = 'none';
}
let activeCivilian = civilians.find(c => !c.arrested);
if (activeCivilian) {
let dCiv = Math.round(playerPos.distanceTo(activeCivilian.mesh.position));
markerCivilian.innerText = `CIVILIAN [${dCiv}m]`;
updateWaypointPosition(activeCivilian.mesh.position, markerCivilian);
markerCivilian.style.display = 'block';
} else {
markerCivilian.style.display = 'none';
}
let nearestEnemy = enemies.length > 0 ? enemies[0].mesh.position : null;
if (nearestEnemy) {
let dEnemy = Math.round(playerPos.distanceTo(nearestEnemy));
markerEnemy.innerText = `HOSTILE [${dEnemy}m]`;
updateWaypointPosition(nearestEnemy, markerEnemy);
markerEnemy.style.display = 'block';
} else {
markerEnemy.style.display = 'none';
}
}
function updateWaypointPosition(worldPos, element) {
let tempVector = worldPos.clone();
tempVector.project(camera);
if (tempVector.z > 1 || tempVector.x < -1 || tempVector.x > 1 || tempVector.y < -1 || tempVector.y > 1) {
element.style.display = 'none';
return;
}
let x = (tempVector.x * .5 + .5) * window.innerWidth;
let y = (tempVector.y * -.5 + .5) * window.innerHeight;
element.style.display = 'block';
element.style.transform = `translate(-50%, -50%) translate(${x}px, ${y}px)`;
}
function checkInteractions() {
const playerPos = new THREE.Vector3(player.x, 2.2, player.z);
keycards.forEach(k => {
if (!k.collected && playerPos.distanceTo(k.mesh.position) < 2.5) {
k.collected = true;
scene.remove(k.mesh);
player.keycards++;
playPillSound();
speakRadio("Alpha-2: Keycard acquired!");
updateHUD();
}
});
targetCivilianToArrest = null;
civilians.forEach(c => {
if (!c.arrested && playerPos.distanceTo(c.mesh.position) < 3.2) {
targetCivilianToArrest = c;
}
});
if (targetCivilianToArrest) {
interactionPrompt.style.display = 'block';
interactionPrompt.innerText = "PRESS [O] TO ARREST CIVILIAN";
} else if (!targetDoorToBreach) {
interactionPrompt.style.display = 'none';
}
targetDoorToBreach = null;
doors.forEach(d => {
if (!d.isBreached && playerPos.distanceTo(new THREE.Vector3(d.x, 2, d.z)) < 3.5) {
targetDoorToBreach = d;
}
});
if (targetDoorToBreach && !targetCivilianToArrest) {
interactionPrompt.style.display = 'block';
if (keys.u) {
uKeyHoldTime += 0.016;
interactionPrompt.innerText = `BREACHING DOOR... [${Math.min(100, Math.round(uKeyHoldTime * 100))}%]`;
if (uKeyHoldTime >= 1.0) {
targetDoorToBreach.isBreached = true;
scene.remove(targetDoorToBreach.mesh);
playBreachSound();
speakRadio("Alpha-2: Door breached!");
interactionPrompt.style.display = 'none';
uKeyHoldTime = 0;
}
} else {
uKeyHoldTime = 0;
interactionPrompt.innerText = "HOLD [U] TO BREACH DOOR";
}
} else if (!targetCivilianToArrest && !targetDoorToBreach) {
interactionPrompt.style.display = 'none';
uKeyHoldTime = 0;
}
}
function animate() {
requestAnimationFrame(animate);
if (!player.isDead) {
player.rotY += (player.targetRotY - player.rotY) * 0.15;
player.rotX += (player.targetRotX - player.rotX) * 0.15;
let moveSpeed = 0.092;
let dx = 0, dz = 0;
if (keys.w) { dz -= Math.cos(player.rotY) * moveSpeed; dx -= Math.sin(player.rotY) * moveSpeed; }
if (keys.s) { dz += Math.cos(player.rotY) * moveSpeed; dx += Math.sin(player.rotY) * moveSpeed; }
if (keys.a) { dx -= Math.cos(player.rotY) * moveSpeed; dz += Math.sin(player.rotY) * moveSpeed; }
if (keys.d) { dx += Math.cos(player.rotY) * moveSpeed; dz -= Math.sin(player.rotY) * moveSpeed; }
let nextX = player.x + dx;
let nextZ = player.z + dz;
let collision = false;
for (let w of walls) {
if (nextX > w.x - w.w/2 - 1.2 && nextX < w.x + w.w/2 + 1.2 &&
nextZ > w.z - w.d/2 - 1.2 && nextZ < w.z + w.d/2 + 1.2) {
collision = true;
break;
}
}
for (let d of doors) {
if (!d.isBreached && nextX > d.x - 1.6 && nextX < d.x + 1.6 &&
nextZ > d.z - 0.6 && nextZ < d.z + 0.6) {
collision = true;
break;
}
}
if (!collision) {
player.x = nextX;
player.z = nextZ;
}
if (currentCamIndex === -1) {
camera.position.x = player.x;
camera.position.y = 2.2 + Math.sin(Date.now() * 0.008) * 0.03;
camera.position.z = player.z;
camera.rotation.y = player.rotY;
camera.rotation.x = player.rotX;
if(weaponModelGroup) weaponModelGroup.visible = true;
} else {
let cam = securityCameras[currentCamIndex];
camera.position.copy(cam.position);
camera.rotation.copy(cam.rotation);
if(weaponModelGroup) weaponModelGroup.visible = false;
}
enemies.forEach(en => {
let enMesh = en.mesh;
let targetDir = new THREE.Vector3(player.x - enMesh.position.x, 0, player.z - enMesh.position.z);
let dist = targetDir.length();
targetDir.normalize();
if (dist > 2.2) {
enMesh.position.addScaledVector(targetDir, en.speed);
enMesh.lookAt(player.x, enMesh.position.y, player.z);
} else {
if (Math.random() < 0.035) takeDamage(12);
}
});
grenades.forEach((g, index) => {
g.velocity.y -= 0.022;
g.pos.add(g.velocity);
if (g.pos.y <= 0.35) {
g.pos.y = 0.35;
g.velocity.y = -g.velocity.y * 0.35;
g.velocity.x *= 0.75;
g.velocity.z *= 0.75;
}
g.mesh.position.copy(g.pos);
g.life--;
if (g.life <= 0) {
playExplosionSound();
scene.remove(g.mesh);
grenades.splice(index, 1);
enemies.forEach((en, eIdx) => {
if (en.mesh.position.distanceTo(g.pos) < 10) {
spawnBloodPool(en.mesh.position);
scene.remove(en.mesh);
enemies.splice(eIdx, 1);
player.money += 400;
updateHUD();
checkLevelCompletion();
}
});
}
});
checkInteractions();
updateWaypoints();
}
drawECG();
renderer.render(scene, camera);
}
function drawECG() {
ecgCtx.fillStyle = 'rgba(10, 10, 15, 0.25)';
ecgCtx.fillRect(0, 0, ecgCanvas.width, ecgCanvas.height);
ecgCtx.strokeStyle = player.isDead ? '#ff0000' : '#00ffcc';
ecgCtx.lineWidth = 2;
ecgCtx.beginPath();
let x = ecgOffset;
let y = ecgCanvas.height / 2;
ecgCtx.moveTo(x, y);
if (player.isDead) {
ecgCtx.lineTo(ecgCanvas.width, y);
} else {
for (let i = 0; i < 50; i++) {
let px = (ecgOffset + i) % ecgCanvas.width;
let py = y;
if (i % 25 === 12) py -= Math.random() * 32 * (heartRate / 75);
if (i % 25 === 14) py += Math.random() * 42 * (heartRate / 75);
ecgCtx.lineTo(px, py);
}
}
ecgCtx.stroke();
let ecgSpeed = Math.max(2, Math.round(heartRate / 22));
ecgOffset = (ecgOffset + ecgSpeed) % ecgCanvas.width;
if (heartRate > 75 && !player.isDead) heartRate -= 0.032;
let now = Date.now();
let interval = 60000 / heartRate;
if (!player.isDead && now - lastHeartbeatTime > interval) {
playHeartbeatThump();
lastHeartbeatTime = now;
}
}
</script>
</body>
</html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TACTICAL BODYCAM: PITCH BLACK INVESTIGATION</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
user-select: none;
}
body, html {
width: 100%;
height: 100%;
overflow: hidden;
background-color: #010103;
font-family: 'Courier New', Courier, monospace;
}
#game-container {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
}
.bodycam-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
z-index: 10;
box-shadow: inset 0 0 160px rgba(0,0,0,0.98);
}
#nv-filter {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
z-index: 8;
background: rgba(0, 255, 60, 0.16);
mix-blend-mode: screen;
display: none;
box-shadow: inset 0 0 120px rgba(0,255,60,0.5);
}
#sniper-scope {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
z-index: 25;
display: none;
background: radial-gradient(circle, transparent 28%, rgba(0,0,0,0.94) 62%);
border: 2px solid rgba(0, 255, 204, 0.5);
}
.scope-crosshair-h {
position: absolute;
top: 50%;
left: 0;
width: 100%;
height: 1px;
background: rgba(0, 255, 204, 0.7);
}
.scope-crosshair-v {
position: absolute;
top: 0;
left: 50%;
width: 1px;
height: 100%;
background: rgba(0, 255, 204, 0.7);
}
.hud-top-left {
position: absolute;
top: 30px;
left: 40px;
color: #fff;
font-size: 20px;
font-weight: bold;
letter-spacing: 2px;
text-shadow: 0 0 6px rgba(255,255,255,0.8);
display: flex;
align-items: center;
gap: 15px;
}
.rec-dot {
width: 14px;
height: 14px;
background-color: #ff0000;
border-radius: 50%;
box-shadow: 0 0 12px #ff0000;
animation: blink 1s infinite;
}
@keyframes blink {