// Spriječi pinch-zoom i double-tap zoom document.addEventListener('gesturestart', function (e) { e.preventDefault(); }); document.addEventListener('gesturechange', function (e) { e.preventDefault(); }); document.addEventListener('gestureend', function (e) { e.preventDefault(); }); document.addEventListener('touchstart', function preventZoom(e) { if (e.touches.length > 1) { e.preventDefault(); } }, { passive: false }); let lastTouchEnd = 0; document.addEventListener('touchend', function (e) { const now = new Date().getTime(); if (now - lastTouchEnd <= 300) { e.preventDefault(); } lastTouchEnd = now; }, false); // Spriječi scroll (opcionalno) document.body.style.overflow = 'hidden'; document.body.style.touchAction = 'none';
LUD Kafić
Napravi 5 bodova i osvoji piće!
Skupljaj bodove i osvoji pogodnosti!
Ostavi nam recenziju:
Made with ❤️ by LUD Agency
const canvas = document.getElementById('canvas'); const ctx = canvas.getContext('2d'); const startOverlay = document.getElementById('startOverlay'); const startBtn = document.getElementById('startBtn'); const gravity = 0.5; const jump = -9; const pipeWidth = 60; const pipeGap = 180; const birdSize = 40; const birdX = 80; let birdY = canvas.height / 2; let velocity = 0; let pipes = []; let score = 0; let bestScore = 0; let gamePlaying = false; function resetGame() { birdY = canvas.height / 2; velocity = 0; score = 0; pipes = []; for (let i = 0; i < 3; i++) { pipes.push({ x: canvas.width + i * 250, height: Math.floor(Math.random() * (canvas.height - pipeGap - 100)) + 50, passed: false }); } } function drawPipes() { ctx.fillStyle = "#5EE270"; pipes.forEach(pipe => { ctx.fillRect(pipe.x, 0, pipeWidth, pipe.height); ctx.fillRect(pipe.x, pipe.height + pipeGap, pipeWidth, canvas.height); }); } function updatePipes() { pipes.forEach(pipe => { pipe.x -= 3; if ( birdX + birdSize > pipe.x && birdX < pipe.x + pipeWidth && (birdY < pipe.height || birdY + birdSize > pipe.height + pipeGap) ) { gamePlaying = false; startOverlay.style.display = "flex"; } if (!pipe.passed && pipe.x + pipeWidth < birdX) { score++; pipe.passed = true; if (score > bestScore) bestScore = score; } }); if (pipes[0].x < -pipeWidth) { pipes.shift(); pipes.push({ x: pipes[pipes.length - 1].x + 250, height: Math.floor(Math.random() * (canvas.height - pipeGap - 100)) + 50, passed: false }); } } function drawBird() { ctx.fillStyle = "#ffffff"; ctx.beginPath(); ctx.arc(birdX + birdSize / 2, birdY + birdSize / 2, birdSize / 2, 0, Math.PI * 2); ctx.fill(); } function drawDarkBottom() { const h = 60; ctx.fillStyle = "rgba(0,0,0,0.35)"; ctx.fillRect(0, canvas.height - h, canvas.width, h); } function gameLoop() { ctx.clearRect(0, 0, canvas.width, canvas.height); drawPipes(); drawBird(); drawDarkBottom(); if (gamePlaying) { velocity += gravity; birdY += velocity; updatePipes(); if (birdY + birdSize > canvas.height || birdY < 0) { gamePlaying = false; startOverlay.style.display = "flex"; } document.getElementById('currentScore').innerText = `Score: ${score}`; document.getElementById('bestScore').innerText = `Best: ${bestScore}`; } requestAnimationFrame(gameLoop); } startBtn.addEventListener('click', () => { resetGame(); gamePlaying = true; velocity = jump; startOverlay.style.display = "none"; }); const handleJump = () => { if (gamePlaying) velocity = jump; }; window.addEventListener('click', handleJump); window.addEventListener('touchstart', handleJump); resetGame(); gameLoop(); // Spriječi pinch-zoom i double-tap zoom document.addEventListener('gesturestart', function (e) { e.preventDefault(); }); document.addEventListener('gesturechange', function (e) { e.preventDefault(); }); document.addEventListener('gestureend', function (e) { e.preventDefault(); }); document.addEventListener('touchstart', function preventZoom(e) { if (e.touches.length > 1) { e.preventDefault(); } }, { passive: false }); let lastTouchEnd = 0; document.addEventListener('touchend', function (e) { const now = new Date().getTime(); if (now - lastTouchEnd <= 300) { e.preventDefault(); } lastTouchEnd = now; }, false); // Spriječi scroll (opcionalno) document.body.style.overflow = 'hidden'; document.body.style.touchAction = 'none';