Meta Description" name="description" />
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<title>Hill Climb Racing Mobile Fix</title>
<style>
body { margin: 0; overflow: hidden; background: #87CEEB; font-family: sans-serif; }
#stats { position: absolute; top: 15px; left: 15px; color: white; text-shadow: 2px 2px #000; z-index: 100; font-size: 20px; font-weight: bold; }
#f-bar { width: 120px; height: 15px; background: #444; border: 2px solid #fff; margin-top: 5px; }
#f-level { width: 100%; height: 100%; background: #ff0000; }
#controls { position: absolute; bottom: 40px; width: 100%; display: flex; justify-content: space-around; z-index: 100; }
.btn { width: 90px; height: 90px; background: rgba(0,0,0,0.8); border: 4px solid #fff; border-radius: 50%; color: #fff; display: flex; justify-content: center; align-items: center; font-weight: bold; font-size: 16px; user-select: none; -webkit-tap-highlight-color: transparent; }
canvas { display: block; touch-action: none; }
</style>
</head>
<body>
<div id="stats">
COINS: <span id="c">0</span><br>
FUEL: <div id="f-bar"><div id="f-level"></div></div>
</div>
<div id="controls">
<div class="btn" id="bBtn">BRAKE</div>
<div class="btn" id="gBtn">GAS</div>
</div>
<canvas id="game"></canvas>
<script>
const canvas = document.getElementById('game');
const ctx = canvas.getContext('2d');
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
let car = { x: 120, y: canvas.height/2, vY: 0, rot: 0, speed: 0, fuel: 100, coins: 0 };
let terrain = [];
let items = [];
let scrollX = 0;
let gas = false, brake = false;
// Rasta (Terrain) aur Items Banana
const mid = canvas.height * 0.65; // Rasta screen ke nichle hisse mein
for (let i = 0; i < 5000; i++) {
let y = mid + Math.sin(i * 0.1) * 50 + Math.cos(i * 0.05) * 30;
terrain.push(y);
if (i > 30 && i % 45 === 0) items.push({ x: i * 25, y: y - 50, type: 'coin', hit: false });
if (i > 80 && i % 250 === 0) items.push({ x: i * 25, y: y - 60, type: 'fuel', hit: false });
}
function getH(x) {
let idx = Math.floor(x / 25);
return terrain[idx] || canvas.height;
}
function update() {
if (gas && car.fuel > 0) {
car.speed += 0.3;
car.fuel -= 0.15;
} else {
car.speed *= 0.97;
}
if (brake) car.speed -= 0.6;
car.speed = Math.max(-3, Math.min(car.speed, 11));
scrollX += car.speed;
let gy = getH(scrollX + car.x);
let gyNext = getH(scrollX + car.x + 30);
let angle = Math.atan2(gyNext - gy, 30);
// JUMP Physics
if (car.y < gy - 35) {
car.vY += 0.6; // Gravity
car.rot += 0.03; // Air Rotation
} else {
car.vY = 0;
car.y = gy - 35;
car.rot = angle;
}
car.y += car.vY;
// Collect Items
items.forEach(it => {
if (!it.hit && Math.abs((scrollX + car.x) - it.x) < 40 && Math.abs(car.y - it.y) < 40) {
it.hit = true;
if (it.type === 'coin') car.coins += 10;
else car.fuel = Math.min(100, car.fuel + 50);
}
});
document.getElementById('c').innerText = car.coins;
document.getElementById('f-level').style.width = car.fuel + "%";
}
function draw() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
// Zameen (Terrain)
ctx.fillStyle = "#8B4513";
ctx.beginPath();
ctx.moveTo(0, canvas.height);
for (let i = 0; i < canvas.width; i += 10) {
ctx.lineTo(i, getH(scrollX + i));
}
ctx.lineTo(canvas.width, canvas.height);
ctx.fill();
// Items (Coins/Fuel)
items.forEach(it => {
if (it.hit) return;
let sx = it.x - scrollX;
if (sx > -50 && sx < canvas.width + 50) {
ctx.fillStyle = it.type === 'coin' ? "#FFD700" : "#ff4444";
ctx.beginPath();
ctx.arc(sx, it.y, it.type === 'coin' ? 10 : 15, 0, Math.PI*2);
ctx.fill();
ctx.fillStyle = "#fff";
ctx.font = "bold 12px Arial";
ctx.fillText(it.type === 'coin' ? "$" : "F", sx-4, it.y+4);
}
});
// Car (Laal Gadi)
ctx.save();
ctx.translate(car.x, car.y);
ctx.rotate(car.rot);
ctx.fillStyle = "#ff0000";
ctx.fillRect(-30, -15, 60, 25); // Car Body
ctx.fillStyle = "#222";
ctx.beginPath(); ctx.arc(-20, 15, 12, 0, Math.PI*2); ctx.fill(); // Wheel Left
ctx.beginPath(); ctx.arc(20, 15, 12, 0, Math.PI*2); ctx.fill(); // Wheel Right
ctx.restore();
}
// Control Buttons
const g = document.getElementById('gBtn'), b = document.getElementById('bBtn');
const startGas = (e) => { e.preventDefault(); gas = true; };
const endGas = () => gas = false;
const startBrake = (e) => { e.preventDefault(); brake = true; };
const endBrake = () => brake = false;
g.addEventListener('touchstart', startGas);
g.addEventListener('touchend', endGas);
b.addEventListener('touchstart', startBrake);
b.addEventListener('touchend', endBrake);
function loop() {
update(); draw();
requestAnimationFrame(loop);
}
loop();
</script>
</body>
</html>
1
1
6KB
6KB
110.0ms
184.0ms
110.0ms