Meta Description" name="description" />

Share this result

Previews are deleted daily. Get a permanent share link sent to your inbox:
Script
<!DOCTYPE html> <html> <head> <title>Car Game with Coins</title> <style> body { margin: 0; overflow: hidden; background: #222; } canvas { display: block; margin: auto; background: #555; } </style> </head> <body> <canvas id="gameCanvas" width="400" height="600"></canvas> <script> const canvas = document.getElementById("gameCanvas"); const ctx = canvas.getContext("2d"); // Player car let car = { x: 180, y: 500, width: 40, height: 80, speed: 5 }; // Obstacle let obstacle = { x: Math.random() * 360, y: -100, width: 40, height: 80, speed: 4 }; // Coin let coin = { x: Math.random() * 360, y: -50, radius: 10, speed: 3 }; let score = 0; let coins = 0; let gameOver = false; // Controls let keys = {}; document.addEventListener("keydown", e => keys[e.key] = true); document.addEventListener("keyup", e => keys[e.key] = false); // Update function update() { if (gameOver) return; // Move car if (keys["ArrowLeft"] && car.x > 0) car.x -= car.speed; if (keys["ArrowRight"] && car.x < canvas.width - car.width) car.x += car.speed; // Move obstacle obstacle.y += obstacle.speed; if (obstacle.y > canvas.height) { obstacle.y = -100; obstacle.x = Math.random() * 360; score++; } // Move coin coin.y += coin.speed; if (coin.y > canvas.height) { coin.y = -50; coin.x = Math.random() * 360; } // Coin collision if ( car.x < coin.x + coin.radius && car.x + car.width > coin.x - coin.radius && car.y < coin.y + coin.radius && car.y + car.height > coin.y - coin.radius ) { coins++; coin.y = -50; coin.x = Math.random() * 360; } // Obstacle collision if ( car.x < obstacle.x + obstacle.width && car.x + car.width > obstacle.x && car.y < obstacle.y + obstacle.height && car.y + car.height > obstacle.y ) { gameOver = true; alert("πŸ’₯ Game Over!\nScore: " + score + "\nCoins: " + coins); location.reload(); } } // Draw function draw() { ctx.clearRect(0, 0, canvas.width, canvas.height); // Road line ctx.fillStyle = "white"; for (let i = 0; i < canvas.height; i += 40) { ctx.fillRect(195, i, 10, 20); } // Car ctx.fillStyle = "blue"; ctx.fillRect(car.x, car.y, car.width, car.height); // Obstacle ctx.fillStyle = "red"; ctx.fillRect(obstacle.x, obstacle.y, obstacle.width, obstacle.height); // Coin ctx.fillStyle = "gold"; ctx.beginPath(); ctx.arc(coin.x, coin.y, coin.radius, 0, Math.PI * 2); ctx.fill(); // Text ctx.fillStyle = "white"; ctx.font = "20px Arial"; ctx.fillText("Score: " + score, 10, 30); ctx.fillText("Coins: " + coins, 10, 60); } // Loop function gameLoop() { update(); draw(); requestAnimationFrame(gameLoop); } gameLoop(); </script> </body> </html>
Landing Page
This ad does not have a landing page available
Network Timeline
Performance Summary

1

Requests

1

Domains

3KB

Transfer Size

3KB

Content Size

107.0ms

Dom Content Loaded

124.0ms

First Paint

107.0ms

Load Time
Domain Breakdown
Transfer Size (bytes)
Loading...
Content Size (bytes)
Loading...
Header Size (bytes)
Loading...
Requests
Loading...
Timings (ms)
Loading...
Total Time
Loading...
Content Breakdown
Transfer Size (bytes)
Loading...
Content Size (bytes)
Loading...
Header Size (bytes)
Loading...
Requests
Loading...