0% found this document useful (0 votes)
41 views3 pages

Jeu 3d HTML Python Gaming gpt5

The document is an HTML file for a 3D game titled 'TIGER RUSH 3D - FULL CONTROL'. It includes JavaScript code that initializes a 3D scene using Three.js, allowing a player to move and avoid obstacles while keeping track of the score. The game ends when the player collides with an obstacle, prompting a game over alert and resetting the game state.

Uploaded by

zomboky
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views3 pages

Jeu 3d HTML Python Gaming gpt5

The document is an HTML file for a 3D game titled 'TIGER RUSH 3D - FULL CONTROL'. It includes JavaScript code that initializes a 3D scene using Three.js, allowing a player to move and avoid obstacles while keeping track of the score. The game ends when the player collides with an obstacle, prompting a game over alert and resetting the game state.

Uploaded by

zomboky
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

<!

DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>TIGER RUSH 3D - FULL CONTROL</title>
<style>
html, body {
margin: 0;
overflow: hidden;
background: black;
}
#ui {
position: absolute;
top: 10px;
left: 10px;
color: #00ffff;
font-family: monospace;
font-size: 18px;
z-index: 1;
}
</style>
</head>
<body>
<div id="ui">Score: <span id="score">0</span></div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/build/three.min.js"></
script>
<script>
let scene, camera, renderer;
let player, obstacles = [];
let speed = 0.15;
let score = 0;
let isGameOver = false;
let playerTarget = {x: 0, y: 1};
const step = 4;
const possibleX = [-4, 0, 4];
const possibleY = [1, 5, 9];

init();
animate();

function init() {
scene = new THREE.Scene();
scene.fog = new THREE.Fog(0x000000, 20, 80);

camera = new THREE.PerspectiveCamera(75, window.innerWidth/window.innerHeight,


0.1, 1000);
camera.position.set(0, 5, 15);
camera.lookAt(0, 5, 0);

renderer = new THREE.WebGLRenderer({antialias: true});


renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);

const ambient = new THREE.AmbientLight(0x444444);


scene.add(ambient);

const dirLight = new THREE.DirectionalLight(0x00ffff, 1);


dirLight.position.set(0, 10, 10);
scene.add(dirLight);
// Floor
const floorGeo = new THREE.PlaneGeometry(100, 100);
const floorMat = new THREE.MeshBasicMaterial({color: 0x111111, side:
THREE.DoubleSide});
const floor = new THREE.Mesh(floorGeo, floorMat);
floor.rotation.x = -Math.PI / 2;
scene.add(floor);

// Player
const geo = new THREE.BoxGeometry(2, 2, 2);
const mat = new THREE.MeshStandardMaterial({color: 0xff00ff});
player = new THREE.Mesh(geo, mat);
player.position.set(0, 1, 0);
scene.add(player);

// Controls
document.addEventListener('keydown', e => {
if (isGameOver) return;
if (e.key === 'ArrowLeft') movePlayer(-1, 0);
if (e.key === 'ArrowRight') movePlayer(1, 0);
if (e.key === 'ArrowUp') movePlayer(0, 1);
if (e.key === 'ArrowDown') movePlayer(0, -1);
});
}

function movePlayer(dx, dy) {


const newX = playerTarget.x + dx * step;
const newY = playerTarget.y + dy * step;
if (possibleX.includes(newX)) playerTarget.x = newX;
if (possibleY.includes(newY)) playerTarget.y = newY;
}

function spawnObstacle() {
const geo = new THREE.BoxGeometry(2, 2, 2);
const mat = new THREE.MeshStandardMaterial({color: 0x00ffff});
const o = new THREE.Mesh(geo, mat);
o.position.z = -50;
o.position.x = possibleX[Math.floor(Math.random() * possibleX.length)];
o.position.y = possibleY[Math.floor(Math.random() * possibleY.length)];
scene.add(o);
obstacles.push(o);
}

function resetGame() {
// Clean up
for (const o of obstacles) scene.remove(o);
obstacles = [];
score = 0;
speed = 0.15;
isGameOver = false;
playerTarget = {x: 0, y: 1};
player.position.set(0, 1, 0);
document.getElementById("score").textContent = score;
}

function gameOver() {
isGameOver = true;
alert("💀 GAME OVER!\nScore: " + score);
resetGame();
}

function animate() {
requestAnimationFrame(animate);
if (Math.random() < 0.02 && !isGameOver) spawnObstacle();

// Move player smoothly


player.position.x += (playerTarget.x - player.position.x) * 0.2;
player.position.y += (playerTarget.y - player.position.y) * 0.2;

// Move obstacles
if (!isGameOver) {
for (let i = obstacles.length - 1; i >= 0; i--) {
const o = obstacles[i];
o.position.z += speed * 10;
if (o.position.z > 20) {
scene.remove(o);
obstacles.splice(i, 1);
score++;
speed += 0.0015;
document.getElementById("score").textContent = score;
}
// Collision
if (
Math.abs(o.position.z - player.position.z) < 1.5 &&
Math.abs(o.position.x - player.position.x) < 1.5 &&
Math.abs(o.position.y - player.position.y) < 1.5
) {
gameOver();
}
}
}

renderer.render(scene, camera);
}
</script>
</body>
</html>

You might also like