Untitled Game
by GoldenComet7356 lines1.3 KB🛠️ Three.js (3D graphics)
if(right){dx+=Math.cos(player.yaw)*speed;dz-=Math.sin(player.yaw)*speed}
player.x+=dx;
player.z+=dz;
let ground=height(Math.round(player.x),Math.round(player.z));
if((keys.Space||touch.Space)&&player.y<=ground+2.1)player.vy=8;
player.vy-=19*dt;
player.y+=player.vy*dt;
if(player.y<ground+2){
player.y=ground+2;
player.vy=0;
}
// Camera
camera.position.set(player.x,player.y,player.z);
camera.rotation.set(player.pitch,player.yaw,0);
// Animals wandering
animals.forEach(a=>{
a.g.position.x+=Math.sin(now*.0005+a.phase)*dt*.5;
a.g.position.z+=Math.cos(now*.0005+a.phase)*dt*.5;
});
// Birds flying
birds.forEach((b,i)=>{
b.position.x+=Math.sin(now*.0003+i)*dt*2;
b.position.z+=Math.cos(now*.0003+i)*dt*2;
b.position.y+=Math.sin(now*.003+i)*dt*.2;
});
// Hostile mobs moving
mobs.forEach((m,i)=>{
m.position.x+=Math.sin(now*.0003+i)*dt*.4;
m.position.z+=Math.cos(now*.0003+i)*dt*.4;
});
// Day and night
let daylight=(Math.sin(clock)+1)/2;
sun.intensity=.3+daylight*2.2;
scene.background.copy(new THREE.Color(0x101c45).lerp(new THREE.Color(0x87ceeb),daylight));
scene.fog.color.copy(scene.background);
renderer.render(scene,camera);
}
requestAnimationFrame(animate);
addEventListener('resize',()=>{
camera.aspect=innerWidth/innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth,innerHeight);
});
</script>
</body>
</html>Game Source: Untitled Game
Creator: GoldenComet73
Libraries: three
Complexity: moderate (56 lines, 1.3 KB)
The full source code is displayed above on this page.
Remix Instructions
To remix this game, copy the source code above and modify it. Add a ARCADELAB header at the top with "remix_of: untitled-game-goldencomet73" to link back to the original. Then publish at arcadelab.ai/publish.