Welcome to my Website!

This is a paragraph! Here's how you make a link: Neocities.

Here's how you can make bold and italic text.

Here's how you can add an image:

Site hosted by Neocities

Here's how to make a list:

To learn more HTML/CSS, check out these tutorials!

// ===== SETUP ===== const scene = new THREE.Scene(); scene.background = new THREE.Color(0x222222); const camera = new THREE.PerspectiveCamera(75, innerWidth/innerHeight, 0.1, 1000); camera.position.set(0,1.6,5); const renderer = new THREE.WebGLRenderer({antialias:true}); renderer.setSize(innerWidth, innerHeight); document.body.appendChild(renderer.domElement); // Licht scene.add(new THREE.AmbientLight(0xffffff,0.4)); const sun = new THREE.DirectionalLight(0xffffff,1); sun.position.set(10,20,10); scene.add(sun); // UI const ui = document.getElementById("ui"); // ===== MAP ===== const floor = new THREE.Mesh( new THREE.PlaneGeometry(100,100), new THREE.MeshStandardMaterial({color:0x444444}) ); floor.rotation.x = -Math.PI/2; scene.add(floor); function wall(x,z,w=5,h=3){ const m = new THREE.Mesh( new THREE.BoxGeometry(w,h,1), new THREE.MeshStandardMaterial({color:0x666666}) ); m.position.set(x,h/2,z); scene.add(m); } wall(0,-10); wall(10,0); wall(-10,0); // ===== PLAYER ===== let health = 100; let ammo = 30; let maxAmmo = 30; let reloading = false; // Movement const keys = {}; addEventListener("keydown",e=>keys[e.code]=true); addEventListener("keyup",e=>keys[e.code]=false); // Mouse Look let yaw=0,pitch=0; document.body.onclick=()=>document.body.requestPointerLock(); addEventListener("mousemove",e=>{ if(document.pointerLockElement){ yaw -= e.movementX*0.002; pitch -= e.movementY*0.002; pitch = Math.max(-1.5,Math.min(1.5,pitch)); camera.rotation.set(pitch,yaw,0); } }); // ===== ENEMIES ===== const enemies=[]; function spawnEnemy(){ const e = new THREE.Mesh( new THREE.BoxGeometry(1,2,1), new THREE.MeshStandardMaterial({color:0xff0000}) ); e.position.set((Math.random()-0.5)*30,1,(Math.random()-0.5)*30); e.hp=5; scene.add(e); enemies.push(e); } for(let i=0;i<6;i++) spawnEnemy(); // ===== SHOOTING ===== addEventListener("mousedown",()=>{ if(reloading || ammo<=0) return; ammo--; const ray = new THREE.Raycaster(); ray.setFromCamera({ x:(Math.random()-0.5)*0.02, y:(Math.random()-0.5)*0.02 },camera); const hit = ray.intersectObjects(enemies)[0]; if(hit){ hit.object.hp--; hit.object.material.color.set(0xffff00); setTimeout(()=>hit.object.material.color.set(0xff0000),80); if(hit.object.hp<=0){ scene.remove(hit.object); enemies.splice(enemies.indexOf(hit.object),1); spawnEnemy(); } } }); // Reload addEventListener("keydown",e=>{ if(e.code==="KeyR" && !reloading){ reloading=true; setTimeout(()=>{ ammo=maxAmmo; reloading=false; },1200); } }); // ===== LOOP ===== function loop(){ requestAnimationFrame(loop); // Movement let dir = new THREE.Vector3(); if(keys.KeyW) dir.z--; if(keys.KeyS) dir.z++; if(keys.KeyA) dir.x--; if(keys.KeyD) dir.x++; dir.normalize().applyEuler(camera.rotation); camera.position.addScaledVector(dir,0.12); // Enemies AI enemies.forEach(e=>{ const d = camera.position.clone().sub(e.position); if(d.length()<1){ health-=0.2; } else { e.position.add(d.normalize().multiplyScalar(0.03)); } e.lookAt(camera.position); }); // UI ui.innerHTML = ` HP: ${Math.max(0,health|0)}
Ammo: ${ammo}/${maxAmmo}
${reloading?"Reloading...":""} `; if(health<=0){ ui.innerHTML="💀 GAME OVER – Reload Page"; return; } renderer.render(scene,camera); } loop(); addEventListener("resize",()=>{ camera.aspect=innerWidth/innerHeight; camera.updateProjectionMatrix(); renderer.setSize(innerWidth,innerHeight); });