Meta Description" name="description" />
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<title>Asli Hill Climb Racing</title>
<style>
body { margin: 0; overflow: hidden; background: #87CEEB; font-family: 'Arial Black', sans-serif; }
#ui { position: absolute; top: 10px; left: 10px; color: white; text-shadow: 2px 2px #000; }
#fuel-bar-container { width: 150px; height: 15px; background: #555; border: 2px solid white; margin-top: 5px; }
#fuel-bar { width: 100%; height: 100%; background: #ff0000; }
#controls { position: absolute; bottom: 30px; width: 100%; display: flex; justify-content: space-around; }
.btn { width: 85px; height: 85px; background: rgba(0,0,0,0.6); border: 4px solid white; border-radius: 50%; color: white; display: flex; justify-content: center; align-items: center; font-weight: bold; font-size: 14px; user-select: none; }
#game-over { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); color: red; font-size: 40px; display: none; text-align: center; background: rgba(0,0,0,0.8); padding: 20px; border-radius: 10px; }
</style>
</head>
<body>
<div id="ui">
COINS: <span id="coinCount">0</span><br>
FUEL:
<div id="fuel-bar-container"><div id="fuel-bar"></div></div>
</div>
<div id="game-over">GAME OVER!<br><button onclick="location.reload()" style="font-size:20px; padding:10px;">RESTART</button></div>
<div id="controls">
<div class="btn" id="brakeBtn">BRAKE</div>
<div class="btn" id="gasBtn">GAS</div>
</div>
<canvas id="raceCanvas"></canvas>
<script>
const canvas = document.getElementById('raceCanvas');
const ctx = canvas.getContext('2d');
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
let car = { x: 100, y: 0, vY: 0, rot: 0, speed: 0, fuel: 100, coins: 0 };
let terrain = [];
let items = []; // Coins aur Fuel dabba
let scrollX = 0;
let gas = false, brake = false, isGameOver = false;
// Terrain aur Items Generation
for (let i = 0; i < 2000; i++) {
let y = Math.sin(i * 0.1) * 40 + Math.cos(i * 0.05) * 30 + (canvas.height - 150);
terrain.push(y);
// Randomly coins aur fuel dabba dalna
if (i > 20 && i % 25 === 0) items.push({ x: i * 20, y: y - 50, type: 'coin', collected: false });
if (i > 50 && i % 150 === 0) items.push({ x: i * 20, y: y - 60, type: 'fuel', collected: false });
}
function getTY(x) {
let idx = Math.floor(x / 20);
return terrain[idx] || canvas.height;
}
function update() {
if (isGameOver) return;
if (gas && car.fuel > 0) {
car.speed += 0.25;
car.fuel -= 0.15;
} else {
car.speed *= 0.98;
}
if (brake) car.speed -= 0.6;
car.speed = Math.max(-2, Math.min(car.speed, 9));
scrollX += car.speed;
let curY = getTY(scrollX + car.x);
let nextY = getTY(scrollX + car.x + 30);
let targetRot = Math.atan2(nextY - curY, 30);
// Gravity aur Jump
if (car.y < curY - 35) {
car.vY += 0.6;
car.rot += 0.02; // Hawa mein flip
} else {
car.vY = 0;
car.y = curY - 35;
car.rot = targetRot;
}
car.y += car.vY;
// Collect Items
items.forEach(it => {
if (!it.collected && Math.abs((scrollX + car.x) - it.x) < 30 && Math.abs(car.y - it.y) < 40) {
it.collected = true;
if (it.type === 'coin') car.coins += 10;
if (it.type === 'fuel') car.fuel = Math.min(car.fuel + 40, 100);
}
});
// UI Update
document.
1
1
4KB
4KB
88.0ms
112.0ms
88.0ms