Meta Description" name="description" />
DOCTYPE html>
<html lang="hi">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<title>Mobile 3D Diamond Shooter</title>
<style>
body {
margin: 0;
overflow: hidden;
font-family: sans-serif;
background-color: #111;
user-select: none;
}
#ui {
position: absolute;
top: 15px;
left: 15px;
color: #00ffff;
font-size: 24px;
font-weight: bold;
text-shadow: 2px 2px 5px rgba(0,0,0,0.8);
z-index: 10;
}
#crosshair {
position: absolute;
top: 50%;
left: 50%;
width: 10px;
height: 10px;
background: #00ff00;
border: 2px solid #000;
border-radius: 50%;
transform: translate(-50%, -50%);
pointer-events: none;
z-index: 10;
}
/* Mobile Controls UI */
#joystick-zone {
position: absolute;
bottom: 30px;
left: 30px;
width: 130px;
height: 130px;
background: rgba(255, 255, 255, 0.15);
border: 2px solid rgba(255, 255, 255, 0.3);
border-radius: 50%;
z-index: 15;
touch-action: none;
}
#joystick-knob {
position: absolute;
top: 40px;
left: 40px;
width: 50px;
height: 50px;
background: rgba(0, 255, 255, 0.6);
border-radius: 50%;
pointer-events: none;
}
#shoot-btn {
position: absolute;
bottom: 40px;
right: 40px;
width: 90px;
height: 90px;
background: rgba(255, 71, 87, 0.8);
border: 3px solid #fff;
border-radius: 50%;
color: white;
font-size: 16px;
font-weight: bold;
display: flex;
justify-content: center;
align-items: center;
z-index: 15;
box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}
#overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.9);
color: white;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
z-index: 20;
text-align: center;
padding: 20px;
}
#overlay h1 { font-size: 32px; color: #ff4757; margin-bottom: 10px; }
#overlay p { font-size: 16px; color: #ccc; margin: 8px 0; }
.btn {
margin-top: 25px;
padding: 14px 35px;
font-size: 20px;
background: #2ed573;
color: white;
border: none;
border-radius: 8px;
font-weight: bold;
}
</style>
</head>
<body>
<div id="ui">ЁЯТО Diamonds: <span id="score">0</span></div>
<div id="crosshair"></div>
<!-- Mobile Touch UI -->
<div id="joystick-zone"><div id="joystick-knob"></div></div>
<div id="shoot-btn">FIRE</div>
<div id="overlay">
<h1>ЁЯОп MOBILE 3D SHOOTER</h1>
<p>рджреБрд╢реНрдордиреЛрдВ рдХреЛ рдЧреЛрд▓реА рдорд╛рд░реЛ рдФрд░ рдбрд╛рдпрдордВрдбреНрд╕ рдЗрдХрдЯреНрдард╛ рдХрд░реЛ!</p>
<p><b>рдмрд╛рдПрдБ рдЕрдВрдЧреВрдареЗ рд╕реЗ:</b> рдШреВрдореЗрдВ/рдЪрд▓реЗрдВ<br><b>рджрд╛рдПрдБ рд╣рд╛рде рд╕реЗ:</b> рдирд┐рд╢рд╛рдирд╛ рд▓рдЧрд╛рдПрдВ рдФрд░ FIRE рдмрдЯрди рджрдмрд╛рдПрдВ</p>
<button class="btn" id="start-btn">рдЧреЗрдо рд╢реБрд░реВ рдХрд░реЗрдВ</button>
</div>
<!-- Three.js 3D Library -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
<script>
let scene, camera, renderer, bullets = [], enemies = [], diamonds = [];
let score = 0;
let isGameActive = false;
// Movement variables for Mobile Joystick & Look
let moveX = 0, moveZ = 0;
let lookX = 0, lookY = 0;
const overlay = document.getElementById('overlay');
const scoreElement = document.getElementById('score');
const startBtn = document.getElementById('start-btn');
// Scene Setup
scene = new THREE.Scene();
scene.background = new THREE.Color(0x1a1a2e);
scene.fog = new THREE.FogExp2(0x1a1a2e, 0.015);
camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
camera.position.y = 2;
renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
// Lights
scene.add(new THREE.AmbientLight(0xffffff, 0.5));
const dirLight = new THREE.DirectionalLight(0xffffff, 0.8);
dirLight.position.set(20, 40, 20);
scene.add(dirLight);
// Ground Floor & Grid
const floorGeo = new THREE.PlaneGeometry(200, 200);
const floorMat = new THREE.MeshStandardMaterial({ color: 0x16213e, roughness: 0.8 });
const floor = new THREE.Mesh(floorGeo, floorMat);
floor.rotation.x = -Math.PI / 2;
scene.add(floor);
const grid = new THREE.GridHelper(200, 50, 0x00fff5, 0x0f3460);
grid.position.y = 0.01;
scene.add(grid);
// 3D Gun Mesh attached to camera
const gunGroup = new THREE.Group();
const barrelGeo = new THREE.BoxGeometry(0.1, 0.1, 0.6);
const gunMat = new THREE.MeshStandardMaterial({ color: 0x333333, metalness: 0.8, roughness: 0.2 });
const barrel = new THREE.Mesh(barrelGeo, gunMat);
barrel.position.set(0.2, -0.25, -0.5);
gunGroup.add(barrel);
camera.add(gunGroup);
scene.add(camera);
// Start Game Event
startBtn.addEventListener('click', () => {
isGameActive = true;
overlay.style.display = 'none';
});
// --- MOBILE TOUCH CONTROLS LOGIC ---
const joystickZone = document.getElementById('joystick-zone');
const joystickKnob = document.getElementById('joystick-knob');
let joystickCenter = { x: 0, y: 0 };
let joystickTouchId = null;
joystickZone.addEventListener('touchstart', (e) => {
const touch = e.changedTouches[0];
joystickTouchId = touch.identifier;
const rect = joystickZone.getBoundingClientRect();
joystickCenter.x = rect.left + rect.width / 2;
joystickCenter.y = rect.top + rect.height / 2;
});
joystickZone.addEventListener('touchmove', (e) => {
for (let i = 0; i < e.changedTouches.length; i++) {
const touch = e.changedTouches[i];
if (touch.identifier === joystickTouchId) {
let dx = touch.clientX - joystickCenter.x;
let dy = touch.clientY - joystickCenter.y;
let dist = Math.sqrt(dx * dx + dy * dy);
let maxDist = 45;
if (dist > maxDist) {
dx = (dx / dist) * maxDist;
dy = (dy / dist) * maxDist;
}
joystickKnob.style.transform = `translate(${dx}px, ${dy}px)`;
moveX = dx / maxDist;
moveZ = dy / maxDist;
}
}
});
joystickZone.addEventListener('touchend', (e) => {
for (let i = 0; i < e.changedTouches.length; i++) {
if (e.changedTouches[i].identifier === joystickTouchId) {
joystickTouchId = null;
joystickKnob.style.transform = `translate(0px, 0px)`;
moveX = 0;
moveZ = 0;
}
}
});
// Right side screen drag to look around
let lastTouchX = 0, lastTouchY = 0;
document.addEventListener('touchstart', (e) => {
const touch = e.changedTouches[0];
if (touch.clientX > window.innerWidth / 2) {
lastTouchX = touch.clientX;
lastTouchY = touch.clientY;
}
});
document.addEventListener('touchmove', (e) => {
const touch = e.changedTouches[0];
if (touch.clientX > window.innerWidth / 2) {
let deltaX = touch.clientX - lastTouchX;
let deltaY = touch.clientY - lastTouchY;
camera.rotation.y -= deltaX * 0.005;
camera.rotation.x -= deltaY * 0.005;
camera.rotation.x = Math.max(-Math.PI / 2.2, Math.min(Math.PI / 2.2, camera.rotation.x));
lastTouchX = touch.clientX;
lastTouchY = touch.clientY;
}
});
// Shoot Button Logic
document.getElementById('shoot-btn').addEventListener('touchstart', (e) => {
e.preventDefault();
if (!isGameActive) return;
// Recoil
gunGroup.position.z += 0.05;
setTimeout(() => gunGroup.position.z = 0, 50);
// Bullet creation
const bulletGeo = new THREE.SphereGeometry(0.08, 8, 8);
const bulletMat = new THREE.MeshBasicMaterial({ color: 0xffff00 });
const bullet = new THREE.Mesh(bulletGeo, bulletMat);
bullet.position.copy(camera.position);
const dir = new THREE.Vector3(0, 0, -1);
dir.applyQuaternion(camera.quaternion);
bullet.userData = { direction: dir, life: 0 };
bullets.push(bullet);
scene.add(bullet);
});
// Enemy Spawning
function spawnEnemy() {
if (enemies.length >= 6) return;
const enemyGeo = new THREE.BoxGeometry(1.2, 2, 1.2);
const enemyMat = new THREE.MeshStandardMaterial({ color: 0xe74c3c });
const enemy = new THREE.Mesh(enemyGeo, enemyMat);
const angle = Math.random() * Math.PI * 2;
const radius = 20 + Math.random() * 15;
enemy.position.x = camera.position.x + Math.sin(angle) * radius;
enemy.position.z = camera.position.z + Math.cos(angle) * radius;
enemy.position.y = 1;
enemies.push(enemy);
scene.add(enemy);
}
setInterval(spawnEnemy, 2500);
// Spawn Diamond
function spawnDiamond(pos) {
const diamondGeo = new THREE.OctahedronGeometry(0.6, 0);
const diamondMat = new THREE.MeshStandardMaterial({ color: 0x00ffff, emissive: 0x00aaaa });
const diamond = new THREE.Mesh(diamondGeo, diamondMat);
diamond.position.copy(pos);
diamond.position.y = 0.8;
diamonds.push(diamond);
scene.add(diamond);
}
// Game Loop
let prevTime = performance.now();
function animate() {
requestAnimationFrame(animate);
const time = performance.now();
const delta = (time - prevTime) / 1000;
prevTime = time;
if (isGameActive) {
// Move player via joystick inputs
camera.translateX(moveX * 8 * delta);
camera.translateZ(moveZ * 8 * delta);
camera.position.y = 2;
// Update Bullets
for (let i = bullets.length - 1; i >= 0; i--) {
const b = bullets[i];
b.position.addScaledVector(b.userData.direction, 50 * delta);
b.userData.life += delta;
// Bullet & Enemy Collision
for (let j = enemies.length - 1; j >= 0; j--) {
const e = enemies[j];
if (b.position.distanceTo(e.position) < 1.2) {
spawnDiamond(e.position);
scene.remove(e);
enemies.splice(j, 1);
scene.remove(b);
bullets.splice(i, 1);
break;
}
}
if (b.userData.life > 2) {
scene.remove(b);
bullets.splice(i, 1);
}
}
// Update Enemies
for (let e of enemies) {
const dirToPlayer = new THREE.Vector3().subVectors(camera.position, e.position);
dirToPlayer.y = 0;
dirToPlayer.normalize();
e.position.addScaledVector(dirToPlayer, 3 * delta);
e.lookAt(camera.position.x, 1, camera.position.z);
}
// Diamond Collection
for (let k = diamonds.length - 1; k >= 0; k--) {
const d = diamonds[k];
d.rotation.y += 3 * delta;
if (camera.position.distanceTo(d.position) < 2.0) {
score += 1;
scoreElement.innerText = score;
scene.remove(d);
diamonds.splice(k, 1);
}
}
}
renderer.render(scene, camera);
}
window.addEventListener('resize', () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
});
animate();
</script>
</body>
</html>DOCTYPE html>
<html lang="hi">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<title>Mobile 3D Diamond Shooter</title>
<style>
body {
margin: 0;
overflow: hidden;
font-family: sans-serif;
background-color: #111;
user-select: none;
}
#ui {
position: absolute;
top: 15px;
left: 15px;
color: #00ffff;
font-size: 24px;
font-weight: bold;
text-shadow: 2px 2px 5px rgba(0,0,0,0.8);
z-index: 10;
}
#crosshair {
position: absolute;
top: 50%;
left: 50%;
width: 10px;
height: 10px;
background: #00ff00;
border: 2px solid #000;
border-radius: 50%;
transform: translate(-50%, -50%);
pointer-events: none;
z-index: 10;
}
/* Mobile Controls UI */
#joystick-zone {
position: absolute;
bottom: 30px;
left: 30px;
width: 130px;
height: 130px;
background: rgba(255, 255, 255, 0.15);
border: 2px solid rgba(255, 255, 255, 0.3);
border-radius: 50%;
z-index: 15;
touch-action: none;
}
#joystick-knob {
position: absolute;
top: 40px;
left: 40px;
width: 50px;
height: 50px;
background: rgba(0, 255, 255, 0.6);
border-radius: 50%;
pointer-events: none;
}
#shoot-btn {
position: absolute;
bottom: 40px;
right: 40px;
width: 90px;
height: 90px;
background: rgba(255, 71, 87, 0.8);
border: 3px solid #fff;
border-radius: 50%;
color: white;
font-size: 16px;
font-weight: bold;
display: flex;
justify-content: center;
align-items: center;
z-index: 15;
box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}
#overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.9);
color: white;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
z-index: 20;
text-align: center;
padding: 20px;
}
#overlay h1 { font-size: 32px; color: #ff4757; margin-bottom: 10px; }
#overlay p { font-size: 16px; color: #ccc; margin: 8px 0; }
.btn {
margin-top: 25px;
padding: 14px 35px;
font-size: 20px;
background: #2ed573;
color: white;
border: none;
border-radius: 8px;
font-weight: bold;
}
</style>
</head>
<body>
<div id="ui">ЁЯТО Diamonds: <span id="score">0</span></div>
<div id="crosshair"></div>
<!-- Mobile Touch UI -->
<div id="joystick-zone"><div id="joystick-knob"></div></div>
<div id="shoot-btn">FIRE</div>
<div id="overlay">
<h1>ЁЯОп MOBILE 3D SHOOTER</h1>
<p>рджреБрд╢реНрдордиреЛрдВ рдХреЛ рдЧреЛрд▓реА рдорд╛рд░реЛ рдФрд░ рдбрд╛рдпрдордВрдбреНрд╕ рдЗрдХрдЯреНрдард╛ рдХрд░реЛ!</p>
<p><b>рдмрд╛рдПрдБ рдЕрдВрдЧреВрдареЗ рд╕реЗ:</b> рдШреВрдореЗрдВ/рдЪрд▓реЗрдВ<br><b>рджрд╛рдПрдБ рд╣рд╛рде рд╕реЗ:</b> рдирд┐рд╢рд╛рдирд╛ рд▓рдЧрд╛рдПрдВ рдФрд░ FIRE рдмрдЯрди рджрдмрд╛рдПрдВ</p>
<button class="btn" id="start-btn">рдЧреЗрдо рд╢реБрд░реВ рдХрд░реЗрдВ</button>
</div>
<!-- Three.js 3D Library -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
<script>
let scene, camera, renderer, bullets = [], enemies = [], diamonds = [];
let score = 0;
let isGameActive = false;
// Movement variables for Mobile Joystick & Look
let moveX = 0, moveZ = 0;
let lookX = 0, lookY = 0;
const overlay = document.getElementById('overlay');
const scoreElement = document.getElementById('score');
const startBtn = document.getElementById('start-btn');
// Scene Setup
scene = new THREE.Scene();
scene.background = new THREE.Color(0x1a1a2e);
scene.fog = new THREE.FogExp2(0x1a1a2e, 0.015);
camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
camera.position.y = 2;
renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
// Lights
scene.add(new THREE.AmbientLight(0xffffff, 0.5));
const dirLight = new THREE.DirectionalLight(0xffffff, 0.8);
dirLight.position.set(20, 40, 20);
scene.add(dirLight);
// Ground Floor & Grid
const floorGeo = new THREE.PlaneGeometry(200, 200);
const floorMat = new THREE.MeshStandardMaterial({ color: 0x16213e, roughness: 0.8 });
const floor = new THREE.Mesh(floorGeo, floorMat);
floor.rotation.x = -Math.PI / 2;
scene.add(floor);
const grid = new THREE.GridHelper(200, 50, 0x00fff5, 0x0f3460);
grid.position.y = 0.01;
scene.add(grid);
// 3D Gun Mesh attached to camera
const gunGroup = new THREE.Group();
const barrelGeo = new THREE.BoxGeometry(0.1, 0.1, 0.6);
const gunMat = new THREE.MeshStandardMaterial({ color: 0x333333, metalness: 0.8, roughness: 0.2 });
const barrel = new THREE.Mesh(barrelGeo, gunMat);
barrel.position.set(0.2, -0.25, -0.5);
gunGroup.add(barrel);
camera.add(gunGroup);
scene.add(camera);
// Start Game Event
startBtn.addEventListener('click', () => {
isGameActive = true;
overlay.style.display = 'none';
});
// --- MOBILE TOUCH CONTROLS LOGIC ---
const joystickZone = document.getElementById('joystick-zone');
const joystickKnob = document.getElementById('joystick-knob');
let joystickCenter = { x: 0, y: 0 };
let joystickTouchId = null;
joystickZone.addEventListener('touchstart', (e) => {
const touch = e.changedTouches[0];
joystickTouchId = touch.identifier;
const rect = joystickZone.getBoundingClientRect();
joystickCenter.x = rect.left + rect.width / 2;
joystickCenter.y = rect.top + rect.height / 2;
});
joystickZone.addEventListener('touchmove', (e) => {
for (let i = 0; i < e.changedTouches.length; i++) {
const touch = e.changedTouches[i];
if (touch.identifier === joystickTouchId) {
let dx = touch.clientX - joystickCenter.x;
let dy = touch.clientY - joystickCenter.y;
let dist = Math.sqrt(dx * dx + dy * dy);
let maxDist = 45;
if (dist > maxDist) {
dx = (dx / dist) * maxDist;
dy = (dy / dist) * maxDist;
}
joystickKnob.style.transform = `translate(${dx}px, ${dy}px)`;
moveX = dx / maxDist;
moveZ = dy / maxDist;
}
}
});
joystickZone.addEventListener('touchend', (e) => {
for (let i = 0; i < e.changedTouches.length; i++) {
if (e.changedTouches[i].identifier === joystickTouchId) {
joystickTouchId = null;
joystickKnob.style.transform = `translate(0px, 0px)`;
moveX = 0;
moveZ = 0;
}
}
});
// Right side screen drag to look around
let lastTouchX = 0, lastTouchY = 0;
document.addEventListener('touchstart', (e) => {
const touch = e.changedTouches[0];
if (touch.clientX > window.innerWidth / 2) {
lastTouchX = touch.clientX;
lastTouchY = touch.clientY;
}
});
document.addEventListener('touchmove', (e) => {
const touch = e.changedTouches[0];
if (touch.clientX > window.innerWidth / 2) {
let deltaX = touch.clientX - lastTouchX;
let deltaY = touch.clientY - lastTouchY;
camera.rotation.y -= deltaX * 0.005;
camera.rotation.x -= deltaY * 0.005;
camera.rotation.x = Math.max(-Math.PI / 2.2, Math.min(Math.PI / 2.2, camera.rotation.x));
lastTouchX = touch.clientX;
lastTouchY = touch.clientY;
}
});
// Shoot Button Logic
document.getElementById('shoot-btn').addEventListener('touchstart', (e) => {
e.preventDefault();
if (!isGameActive) return;
// Recoil
gunGroup.position.z += 0.05;
setTimeout(() => gunGroup.position.z = 0, 50);
// Bullet creation
const bulletGeo = new THREE.SphereGeometry(0.08, 8, 8);
const bulletMat = new THREE.MeshBasicMaterial({ color: 0xffff00 });
const bullet = new THREE.Mesh(bulletGeo, bulletMat);
bullet.position.copy(camera.position);
const dir = new THREE.Vector3(0, 0, -1);
dir.applyQuaternion(camera.quaternion);
bullet.userData = { direction: dir, life: 0 };
bullets.push(bullet);
scene.add(bullet);
});
// Enemy Spawning
function spawnEnemy() {
if (enemies.length >= 6) return;
const enemyGeo = new THREE.BoxGeometry(1.2, 2, 1.2);
const enemyMat = new THREE.MeshStandardMaterial({ color: 0xe74c3c });
const enemy = new THREE.Mesh(enemyGeo, enemyMat);
const angle = Math.random() * Math.PI * 2;
const radius = 20 + Math.random() * 15;
enemy.position.x = camera.position.x + Math.sin(angle) * radius;
enemy.position.z = camera.position.z + Math.cos(angle) * radius;
enemy.position.y = 1;
enemies.push(enemy);
scene.add(enemy);
}
setInterval(spawnEnemy, 2500);
// Spawn Diamond
function spawnDiamond(pos) {
const diamondGeo = new THREE.OctahedronGeometry(0.6, 0);
const diamondMat = new THREE.MeshStandardMaterial({ color: 0x00ffff, emissive: 0x00aaaa });
const diamond = new THREE.Mesh(diamondGeo, diamondMat);
diamond.position.copy(pos);
diamond.position.y = 0.8;
diamonds.push(diamond);
scene.add(diamond);
}
// Game Loop
let prevTime = performance.now();
function animate() {
requestAnimationFrame(animate);
const time = performance.now();
const delta = (time - prevTime) / 1000;
prevTime = time;
if (isGameActive) {
// Move player via joystick inputs
camera.translateX(moveX * 8 * delta);
camera.translateZ(moveZ * 8 * delta);
camera.position.y = 2;
// Update Bullets
for (let i = bullets.length - 1; i >= 0; i--) {
const b = bullets[i];
b.position.addScaledVector(b.userData.direction, 50 * delta);
b.userData.life += delta;
// Bullet & Enemy Collision
for (let j = enemies.length - 1; j >= 0; j--) {
const e = enemies[j];
if (b.position.distanceTo(e.position) < 1.2) {
spawnDiamond(e.position);
scene.remove(e);
enemies.splice(j, 1);
scene.remove(b);
bullets.splice(i, 1);
break;
}
}
if (b.userData.life > 2) {
scene.remove(b);
bullets.splice(i, 1);
}
}
// Update Enemies
for (let e of enemies) {
const dirToPlayer = new THREE.Vector3().subVectors(camera.position, e.position);
dirToPlayer.y = 0;
dirToPlayer.normalize();
e.position.addScaledVector(dirToPlayer, 3 * delta);
e.lookAt(camera.position.x, 1, camera.position.z);
}
// Diamond Collection
for (let k = diamonds.length - 1; k >= 0; k--) {
const d = diamonds[k];
d.rotation.y += 3 * delta;
if (camera.position.distanceTo(d.position) < 2.0) {
score += 1;
scoreElement.innerText = score;
scene.remove(d);
diamonds.splice(k, 1);
}
}
}
renderer.render(scene, camera);
}
window.addEventListener('resize', () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
});
animate();
</script>
</body>
</html>
Html.game2
2
147KB
617KB
1,438.0ms
144.0ms
1,438.0ms