Share this result

Previews are deleted daily. Get a permanent share link sent to your inbox:
Script
HTML <!DOCTYPE html> <html lang="tr"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Akıcı Direksiyon - Otoyol Trafik Oyunu</title> <style> * { box-sizing: border-box; margin: 0; padding: 0; font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif; } body { background: #0f172a; color: #f8fafc; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; overflow: hidden; user-select: none; } .hud { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); display: flex; gap: 16px; background: rgba(15, 23, 42, 0.82); backdrop-filter: blur(8px); border: 1px solid rgba(148, 163, 184, 0.25); padding: 10px 20px; border-radius: 14px; z-index: 10; font-size: 14px; box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4); } .hud-item strong { color: #38bdf8; font-variant-numeric: tabular-nums; } .controls-hint { position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%); background: rgba(15, 23, 42, 0.75); border: 1px solid rgba(148, 163, 184, 0.2); padding: 8px 16px; border-radius: 999px; font-size: 12.5px; color: #cbd5e1; z-index: 10; white-space: nowrap; } canvas { display: block; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.65); border-radius: 8px; } .overlay { position: fixed; inset: 0; background: rgba(2, 6, 23, 0.72); backdrop-filter: blur(5px); display: none; flex-direction: column; align-items: center; justify-content: center; z-index: 20; text-align: center; gap: 14px; } .overlay.active { display: flex; } .overlay h1 { font-size: 36px; color: #f87171; } .overlay p { font-size: 17px; color: #e2e8f0; } .overlay button { margin-top: 8px; padding: 12px 26px; font-size: 16px; font-weight: 600; border: none; border-radius: 10px; background: #38bdf8; color: #0f172a; cursor: pointer; transition: transform 0.12s ease, background 0.15s ease; } .overlay button:hover { background: #7dd3fc; transform: translateY(-1px); } </style> </head> <body> <div class="hud"> <div class="hud-item">Hız: <strong id="speedText">0 km/s</strong></div> <div class="hud-item">Mesafe: <strong id="distanceText">0 m</strong></div> <div class="hud-item">Skor: <strong id="scoreText">0</strong></div> <div class="hud-item">Direksiyon: <strong id="steerText">0°</strong></div> </div> <canvas id="gameCanvas"></canvas> <div class="controls-hint"> <strong>A / D</strong> veya <strong>◀ / ▶</strong>: Direksiyon &nbsp;|&nbsp; <strong>W / ▲</strong>: Gaz &nbsp;|&nbsp; <strong>S / ▼</strong>: Fren &nbsp;|&nbsp; <strong>R</strong>: Yeniden Başla </div> <div class="overlay" id="gameOverOverlay"> <h1>KAZA YAPTIN!</h1> <p id="finalStats">Mesafe: 0 m | Skor: 0</p> <button id="restartBtn">Tekrar Oyna (R)</button> </div> <script> const canvas = document.getElementById("gameCanvas"); const ctx = canvas.getContext("2d"); const speedText = document.getElementById("speedText"); const distanceText = document.getElementById("distanceText"); const scoreText = document.getElementById("scoreText"); const steerText = document.getElementById("steerText"); const overlay = document.getElementById("gameOverOverlay"); const finalStats = document.getElementById("finalStats"); const restartBtn = document.getElementById("restartBtn"); function resizeCanvas() { const maxWidth = Math.min(window.innerWidth - 24, 540); const maxHeight = Math.min(window.innerHeight - 24, 860); canvas.width = Math.max(340, maxWidth); canvas.height = Math.max(480, maxHeight); } resizeCanvas(); window.addEventListener("resize", resizeCanvas); // Yol ve şerit ayarları const LANE_COUNT = 4; function getRoadMetrics() { const roadWidth = Math.min(canvas.width * 0.82, 420); const roadLeft = (canvas.width - roadWidth) / 2; const roadRight = roadLeft + roadWidth; const laneWidth = roadWidth / LANE_COUNT; return { roadWidth, roadLeft, roadRight, laneWidth }; } const keys = { left: false, right: false, up: false, down: false }; window.addEventListener("keydown", (e) => { if (["ArrowLeft", "KeyA"].includes(e.code)) keys.left = true; if (["ArrowRight", "KeyD"].includes(e.code)) keys.right = true; if (["ArrowUp", "KeyW"].includes(e.code)) keys.up = true; if (["ArrowDown", "KeyS"].includes(e.code)) keys.down = true; if (e.code === "KeyR" && gameOver) { resetGame(); } }); window.addEventListener("keyup", (e) => { if (["ArrowLeft", "KeyA"].includes(e.code)) keys.left = false; if (["ArrowRight", "KeyD"].includes(e.code)) keys.right = false; if (["ArrowUp", "KeyW"].includes(e.code)) keys.up = false; if (["ArrowDown", "KeyS"].includes(e.code)) keys.down = false; }); restartBtn.addEventListener("click", resetGame); // Oyuncu aracı ve hassas direksiyon fiziği const player = { x: 0, y: 0, width: 44, height: 82, speed: 320, // px/sn minSpeed: 120, maxSpeed: 760, steerAngle: 0, // Görsel & fiziksel direksiyon açısı (-1 ile 1 arası) lateralVel: 0, // Yatay hız heading: 0 // Gövde eğimi (radyan) }; let traffic = []; let roadScroll = 0; let distance = 0; let score = 0; let spawnTimer = 0; let gameOver = false; let lastTime = performance.now(); const TRAFFIC_COLORS = ["#ef4444", "#f59e0b", "#10b981", "#a855f7", "#ec4899", "#e2e8f0"]; function resetGame() { const { roadLeft, roadWidth } = getRoadMetrics(); player.x = roadLeft + roadWidth * 0.625; player.y = canvas.height - 135; player.speed = 340; player.steerAngle = 0; player.lateralVel = 0; player.heading = 0; traffic = []; roadScroll = 0; distance = 0; score = 0; spawnTimer = 0.4; gameOver = false; overlay.classList.remove("active"); lastTime = performance.now(); } function spawnTrafficCar() { const { roadLeft, laneWidth } = getRoadMetrics(); const laneIndex = Math.floor(Math.random() * LANE_COUNT); const width = Math.min(44, laneWidth * 0.56); const height = width * 1.85; const laneCenter = roadLeft + laneIndex * laneWidth + laneWidth / 2; // Aynı şeritte üst üste binmeyi engelle const tooClose = traffic.some( (car) => Math.abs(car.x - laneCenter) < laneWidth * 0.7 && car.y < height * 2.4 ); if (tooClose) return; const color = TRAFFIC_COLORS[Math.floor(Math.random() * TRAFFIC_COLORS.length)]; const carSpeed = 160 + Math.random() * 150; traffic.push({ x: laneCenter, y: -height - 20, width, height, speed: carSpeed, color, passed: false }); } function rectsOverlap(a, b) { // Hitbox'ı hafifçe daraltarak adil çarpışma hissi verelim const padX = 5; const padY = 6; const ax1 = a.x - a.width / 2 + padX; const ax2 = a.x + a.width / 2 - padX; const ay1 = a.y - a.height / 2 + padY; const ay2 = a.y + a.height / 2 - padY; const bx1 = b.x - b.width / 2 + padX; const bx2 = b.x + b.width / 2 - padX; const by1 = b.y - b.height / 2 + padY; const by2 = b.y + b.height / 2 - padY; return ax1 < bx2 && ax2 > bx1 && ay1 < by2 && ay2 > by1; } function update(dt) { if (gameOver) return; const { roadLeft, roadRight, laneWidth } = getRoadMetrics(); player.width = Math.min(44, laneWidth * 0.56); player.height = player.width * 1.85; player.y = canvas.height - Math.max(125, player.height + 42); // Gaz ve fren kontrolü if (keys.up) { player.speed += 440 * dt; } else if (keys.down) { player.speed -= 560 * dt; } else { // Hafif motor freni (doğal süzülme) const cruiseSpeed = 350; if (player.speed > cruiseSpeed) { player.speed -= 140 * dt; } else if (player.speed < cruiseSpeed) { player.speed += 90 * dt; } } player.speed = Math.max(player.minSpeed, Math.min(player.maxSpeed, player.speed)); // Akıcı direksiyon dönüşü: tepkisel kırılma + bırakınca yumuşak merkezleme const steerInput = (keys.right ? 1 : 0) - (keys.left ? 1 : 0); if (steerInput !== 0) { // Ters yöne kırarken daha hızlı tepki verir (çevik kontrol) const reversingDirection = Math.sign(player.steerAngle) !== steerInput && Math.abs(player.steerAngle) > 0.05; const turnRate = reversingDirection ? 11.5 : 8.2; player.steerAngle += steerInput * turnRate * dt; } else { // Tuş bırakılınca direksiyon hızlıca merkeze döner const returnRate = 10.5; const delta = -player.steerAngle * Math.min(1, returnRate * dt); player.steerAngle += delta; if (Math.abs(player.steerAngle) < 0.01) player.steerAngle = 0; } player.steerAngle = Math.max(-1, Math.min(1, player.steerAngle)); // Hıza göre dengelenmiş yatay dönüş kuvveti const speedFactor = 0.65 + (player.speed / player.maxSpeed) * 0.55; const targetLateralVel = player.steerAngle * 540 * speedFactor; const lateralResponsiveness = 14; player.lateralVel += (targetLateralVel - player.lateralVel) * Math.min(1, lateralResponsiveness * dt); player.x += player.lateralVel * dt; // Gövde eğimi (direksiyon açısına ve yatay hıza bağlı) const targetHeading = player.steerAngle * 0.22 + (player.lateralVel / 540) * 0.08; player.heading += (targetHeading - player.heading) * Math.min(1, 15 * dt); // Yol kenarı sınırları const halfCar = player.width / 2; if (player.x - halfCar < roadLeft + 4) { player.x = roadLeft + 4 + halfCar; player.lateralVel = Math.max(0, player.lateralVel * 0.3); } if (player.x + halfCar > roadRight - 4) { player.x = roadRight - 4 - halfCar; player.lateralVel = Math.min(0, player.lateralVel * 0.3); } // Yol akışı ve mesafe/skor roadScroll = (roadScroll + player.speed * dt) % 80; const deltaMeters = (player.speed * dt) / 14; distance += deltaMeters; score += deltaMeters * (player.speed / 280); // Trafik araçlarını üret ve ilerlet spawnTimer -= dt; if (spawnTimer <= 0) { spawnTrafficCar(); const densityFactor = Math.max(0.42, 1.05 - (player.speed / player.maxSpeed) * 0.55); spawnTimer = (0.55 + Math.random() * 0.65) * densityFactor; } for (let i = traffic.length - 1; i >= 0; i--) { const car = traffic[i]; // Oyuncu hızına göre bağıl hareket const relativeSpeed = player.speed - car.speed; car.y += relativeSpeed * dt; if (!car.passed && car.y - car.height / 2 > player.y + player.height / 2) { car.passed = true; score += 25; } if (rectsOverlap(player, car)) { triggerGameOver(); return; } if (car.y - car.height > canvas.height + 120 || car.y + car.height < -240) { traffic.splice(i, 1); } } // HUD güncelle const kmh = Math.round(player.speed * 0.32); const deg = Math.round(player.steerAngle * 420); // Tam tur hissi için derece göstergesi speedText.textContent = `${kmh} km/s`; distanceText.textContent = `${Math.floor(distance)} m`; scoreText.textContent = `${Math.floor(score)}`; steerText.textContent = `${deg > 0 ? "+" : ""}${deg}°`; } function triggerGameOver() { gameOver = true; finalStats.textContent = `Mesafe: ${Math.floor(distance)} m | Skor: ${Math.floor(score)}`; overlay.classList.add("active"); } function drawCar(x, y, w, h, color, angle = 0, isPlayer = false) { ctx.save(); ctx.translate(x, y); ctx.rotate(angle); // Gölge ctx.fillStyle = "rgba(0, 0, 0, 0.38)"; ctx.beginPath(); ctx.roundRect(-w / 2 + 3, -h / 2 + 5, w, h, 9); ctx.fill(); // Araç gövdesi ctx.fillStyle = color; ctx.beginPath(); ctx.roundRect(-w / 2, -h / 2, w, h, 9); ctx.fill(); // İnce kenar çizgisi ctx.strokeStyle = isPlayer ? "#bae6fd" : "rgba(15, 23, 42, 0.45)"; ctx.lineWidth = isPlayer ? 2 : 1.5; ctx.stroke(); // Ön ve arka cam ctx.fillStyle = "#0f172a"; ctx.beginPath(); ctx.roundRect(-w * 0.36, -h * 0.24, w * 0.72, h * 0.2, 4); ctx.roundRect(-w * 0.34, h * 0.12, w * 0.68, h * 0.14, 3); ctx.fill(); // Tavan ctx.fillStyle = color; ctx.beginPath(); ctx.roundRect(-w * 0.32, -h * 0.06, w * 0.64, h * 0.2, 4); ctx.fill(); // Farlar ve stoplar ctx.fillStyle = "#fef08a"; ctx.fillRect(-w * 0.36, -h / 2 + 2, w * 0.2, 4); ctx.fillRect(w * 0.16, -h / 2 + 2, w * 0.2, 4); ctx.fillStyle = "#ef4444"; ctx.fillRect(-w * 0.36, h / 2 - 5, w * 0.2, 4); ctx.fillRect(w * 0.16, h / 2 - 5, w * 0.2, 4); ctx.restore(); } function drawSteeringWheelIndicator() { // Sağ alt köşede gerçek zamanlı direksiyon simidi göstergesi const cx = canvas.width - 54; const cy = canvas.height - 54; const r = 28; ctx.save(); ctx.translate(cx, cy); ctx.fillStyle = "rgba(15, 23, 42, 0.78)"; ctx.beginPath(); ctx.arc(0, 0, r + 6, 0, Math.PI * 2); ctx.fill(); ctx.rotate(player.steerAngle * 1.35); ctx.strokeStyle = "#38bdf8"; ctx.lineWidth = 5; ctx.beginPath(); ctx.arc(0, 0, r - 4, 0, Math.PI * 2); ctx.stroke(); // Direksiyon kolları ctx.lineWidth = 4; ctx.beginPath(); ctx.moveTo(-r + 5, 0); ctx.lineTo(r - 5, 0); ctx.moveTo(0, 0); ctx.lineTo(0, r - 5); ctx.stroke(); // Üst merkez işareti ctx.fillStyle = "#f97316"; ctx.beginPath(); ctx.arc(0, -(r - 4), 4, 0, Math.PI * 2); ctx.fill(); ctx.restore(); } function render() { const { roadLeft, roadRight, laneWidth } = getRoadMetrics(); // Yol kenarı zemin ctx.fillStyle = "#14532d"; ctx.fillRect(0, 0, canvas.width, canvas.height); // Asfalt zemin ctx.fillStyle = "#1e293b"; ctx.fillRect(roadLeft, 0, roadRight - roadLeft, canvas.height); // Sol ve sağ emniyet çizgileri ctx.fillStyle = "#f8fafc"; ctx.fillRect(roadLeft, 0, 5, canvas.height); ctx.fillRect(roadRight - 5, 0, 5, canvas.height); // Hareketli şerit çizgileri ctx.fillStyle = "rgba(248, 250, 252, 0.55)"; const dashHeight = 40; const dashGap = 40; const step = dashHeight + dashGap; for (let lane = 1; lane < LANE_COUNT; lane++) { const lineX = roadLeft + lane * laneWidth - 2; for (let y = -step + roadScroll; y < canvas.height + step; y += step) { ctx.fillRect(lineX, y, 4, dashHeight); } } // Trafik araçları for (const car of traffic) { drawCar(car.x, car.y, car.width, car.height, car.color, 0, false); } // Oyuncu aracı drawCar(player.x, player.y, player.width, player.height, "#38bdf8", player.heading, true); // Direksiyon göstergesi drawSteeringWheelIndicator(); } function loop(now) { const dt = Math.min(0.05, (now - lastTime) / 1000); lastTime = now; update(dt); render(); requestAnimationFrame(loop); } resetGame(); requestAnimationFrame(loop); </script>
Landing Page
This ad does not have a landing page available
Network Timeline
Performance Summary

1

Requests

1

Domains

17KB

Transfer Size

17KB

Content Size

390.0ms

Dom Content Loaded

588.0ms

First Paint

392.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...