Meta Description" name="description" />
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Slow Roads Mobile</title>
<style>
body { margin: 0; overflow: hidden; background: #1a1a2e; font-family: sans-serif; }
canvas { display: block; width: 100vw; height: 100vh; touch-action: none; }
#ui { position: absolute; top: 20px; left: 20px; color: #e94560; font-size: 20px; pointer-events: none; }
#controls { position: absolute; bottom: 30px; width: 100%; display: flex; justify-content: space-around; }
.btn { width: 80px; height: 80px; background: rgba(255,255,255,0.1); border-radius: 50%; border: 2px solid #e94560; color: white; display: flex; align-items: center; justify-content: center; user-select: none; -webkit-tap-highlight-color: transparent; }
</style>
</head>
<body>
<div id="ui">Hız: <span id="speed">0</span> km/h</div>
<div id="controls">
<div class="btn" id="leftBtn">L</div>
<div class="btn" id="accelBtn">GAZ</div>
<div class="btn" id="rightBtn">R</div>
</div>
<canvas id="gameCanvas"></canvas>
<script>
const canvas = document.getElementById('gameCanvas');
const ctx = canvas.getContext('2d');
const speedEl = document.getElementById('speed');
// Ekran boyutlandırma
function resize() {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
}
window.addEventListener('resize', resize);
resize();
// Oyun Değişkenleri
let speed = 0;
let offset = 0;
let playerX = 0;
let curve = 0;
let track = [];
const laneWidth = 1500;
const segL = 200; // Segment uzunluğu
// Track oluştur (Sonsuz yol mantığı)
for(let n = 0; n < 500; n++) {
track.push({
x: Math.sin(n/20) * 1000,
y: n * segL,
z: n * segL
});
}
// Kontroller
let keys = { left: false, right: false, accel: false };
document.getElementById('leftBtn').ontouchstart = () => keys.left = true;
document.getElementById('leftBtn').ontouchend = () => keys.left = false;
document.getElementById('rightBtn').ontouchstart = () => keys.right = true;
document.getElementById('rightBtn').ontouchend = () => keys.right = false;
document.getElementById('accelBtn').ontouchstart = () => keys.accel = true;
document.getElementById('accelBtn').ontouchend = () => keys.accel = false;
function project(p, cameraX, cameraY, cameraZ, cameraDepth) {
const scale = cameraDepth / (p.z - cameraZ);
return {
x: (canvas.width/2) + (p.x - cameraX) * scale * canvas.width/2,
y: (canvas.height/2) - (p.y - cameraY) * scale * canvas.height/2,
w: laneWidth * scale * canvas.width/2
};
}
function draw() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
// Gökyüzü (Gradient)
let grad = ctx.createLinearGradient(0, 0, 0, canvas.height);
grad.addColorStop(0, "#1a1a2e");
grad.addColorStop(1, "#16213e");
ctx.fillStyle = grad;
ctx.fillRect(0,0, canvas.width, canvas.height);
// Hareket mantığı
if (keys.accel) speed = Math.min(speed + 2, 150);
else speed = Math.max(speed - 1, 0);
if (keys.left) playerX -= 0.05 * (speed/50);
if (keys.right) playerX += 0.05 * (speed/50);
offset += speed * 2;
speedEl.innerText = Math.round(speed);
const startNode = Math.floor(offset / segL);
const cameraZ = offset;
const cameraX = playerX * laneWidth + track[startNode % 500].x;
// Yolu Çiz
for(let n = startNode; n < startNode + 40; n++) {
const curr = track[n % 500];
const prev = track[(n-1) % 500];
const camZ = offset;
// Basitleştirilmiş 3D projeksiyon
const p1 = project(curr, cameraX, 500, cameraZ, 0.8);
const p2 = project(prev, cameraX, 500, cameraZ, 0.8);
if (p1.y <= p2.y) continue;
ctx.fillStyle = (n % 2) ? "#444" : "#333";
ctx.beginPath();
ctx.moveTo(p2.x - p2.w, p2.y);
ctx.lineTo(p2.x + p2.w, p2.y);
ctx.lineTo(p1.x + p1.w, p1.y);
ctx.lineTo(p1.x - p1.w, p1.y);
ctx.fill();
// Yan şeritler
ctx.fillStyle = "#e94560";
ctx.fillRect(p1.x - p1.w - 10, p1.y, 20, 5);
ctx.fillRect(p1.x + p1.w - 10, p1.y, 20, 5);
}
// Araba (Oyuncu)
ctx.fillStyle = "#0f3460";
ctx.fillRect(canvas.width/2 - 30, canvas.height - 120, 60, 40);
ctx.fillStyle = "#e94560"; // Stop lambaları
ctx.fillRect(canvas.width/2 - 25, canvas.height - 90, 10, 5);
ctx.fillRect(canvas.width/2 + 15, canvas.height - 90, 10, 5);
requestAnimationFrame(draw);
}
draw();
</script>
</body>
</html>
1
1
5KB
5KB
587.0ms
684.0ms
587.0ms