Below is a bare-bones, self-contained Flappy-Bird-style clone that runs in any modern mobile or desktop browser.
Copy everything into a single .html file and open it on your phone—no extra assets or build steps required.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0, user-scalable=no">
<title>Flappy Mini</title>
<!-- ——— STYLES ——— -->
<style>
:root {
--sky: #70c5ce;
--pipe: #3fb000;
--bird: #ffeb3b;
}
* { box-sizing: border-box; }
html,body { margin:0; padding:0; background:var(--sky); overflow:hidden; }
canvas { display:block; } /* fills the screen */
#scoreBoard { position:fixed; top:8px; left:50%;
transform:translateX(-50%);
font:600 32px/1 "Helvetica Neue",Arial;
color:#fff; text-shadow:2px 2px 0 #000; }
#restartBtn { position:fixed; top:50%; left:50%;
transform:translate(-50%,-50%);
padding:18px 28px; border:0; border-radius:10px;
font:600 24px/1 Arial; background:#fff; color:#000;
display:none; }
</style>
</head>
<body>
<canvas id="game"></canvas>
<div id="scoreBoard">0</div>
<button id="restartBtn">Tap to restart</button>
<!-- ——— GAME SCRIPT ——— -->
<script>
(() => {
/* ---------- Canvas + Resize ---------- */
const canvas = document.getElementById('game');
const ctx = canvas.getContext('2d');
let W, H;
const resize = () => { W = canvas.width = innerWidth;
H = canvas.height = innerHeight; };
resize(); addEventListener('resize', resize);
/* ---------- Constants ---------- */
const G = 0.55; // gravity
const FLAP = -9.5; // jump velocity
const GAP = 160; // vertical gap between pipes
const PIPE_W = 68; // pipe width
const PIPE_SP = 1500; // ms between pipes
const BIRD_R = 18; // bird radius
/* ---------- State ---------- */
let bird, pipes, score, best = +localStorage.bestScore || 0, lastPipe, playing;
const reset = () => {
bird = { x: W * 0.25, y: H/2, vy: 0, rot: 0 };
pipes = [];
score = 0;
lastPipe = performance.now();
playing = true;
scoreBoard.textContent = '0';
restartBtn.style.display = 'none';
requestAnimationFrame(loop);
};
/* ---------- Input ---------- */
const flap = () => playing && (bird.vy = FLAP);
addEventListener('keydown', e => e.code==='Space' && flap());
addEventListener('mousedown', flap);
addEventListener('touchstart', e => { e.preventDefault(); flap(); }, {passive:false});
/* ---------- Game Loop ---------- */
const update = (dt) => {
/* physics */
bird.vy += G;
bird.y += bird.vy;
bird.rot = Math.atan2(bird.vy, 10);
/* spawn pipes */
if (performance.now() - lastPipe > PIPE_SP) {
const top = Math.random()*(H - GAP - 200) + 50;
pipes.push({ x: W, top, scored:false });
lastPipe = performance.now();
}
/* move & cull pipes */
pipes = pipes.filter(p => {
p.x -= 3;
/* score */
if (!p.scored && p.x + PIPE_W < bird.x) {
p.scored = true; score++; scoreBoard.textContent = score;
}
return p.x + PIPE_W > 0; // keep if onscreen
});
/* collisions (pipes or ground / ceiling) */
const hitWall = bird.y + BIRD_R > H || bird.y - BIRD_R < 0;
const hitPipe = pipes.some(p =>
bird.x + BIRD_R > p.x && bird.x - BIRD_R < p.x + PIPE_W &&
(bird.y - BIRD_R < p.top || bird.y + BIRD_R > p.top + GAP)
);
if (hitWall || hitPipe) gameOver();
};
const draw = () => {
ctx.clearRect(0,0,W,H);
/* pipes */
ctx.fillStyle = getComputedStyle(document.documentElement)
.getPropertyValue('--pipe');
pipes.forEach(p => {
ctx.fillRect(p.x, 0, PIPE_W, p.top); // upper pipe
ctx.fillRect(p.x, p.top + GAP, PIPE_W, H); // lower pipe
});
/* bird */
ctx.save();
ctx.translate(bird.x, bird.y);
ctx.rotate(bird.rot);
ctx.fillStyle = getComputedStyle(document.documentElement)
.getPropertyValue('--bird');
ctx.beginPath();
ctx.arc(0,0,BIRD_R,0,Math.PI*2);
ctx.fill();
ctx.restore();
};
let prevTime = performance.now();
const loop = (t) => {
if (!playing) return;
const dt = t - prevTime; prevTime = t;
update(dt);
draw();
requestAnimationFrame(loop);
};
/* ---------- Game Over ---------- */
const gameOver = () => {
playing = false;
best = Math.max(best, score);
localStorage.bestScore = best;
restartBtn.innerHTML = `
Game Over<br><small>Score: ${score} Best: ${best}</small>`;
restartBtn.style.display = 'block';
};
restartBtn.addEventListener('click', reset);
restartBtn.addEventListener('touchstart', e => {e.preventDefault();reset();},
{passive:false});
/* ---------- Kick-off ---------- */
reset();
})();
</script>
</body>
</html>
How it works (quick tour)
• Canvas + requestAnimationFrame powers drawing/animation.
• Gravity (G) pulls the bird down; a tap sets bird.vy to FLAP for an instant jump.
• Every PIPE_SP ms a new pipe pair is pushed into the pipes array and slides left.
• Collision checks:
• Bird beyond screen top/bottom, or
• Bird x-overlaps a pipe AND y is outside the gap.
• Score/Best score stored in localStorage so it survives reloads.
Try it, tweak numbers (gravity, gap, speed) or swap the plain colored shapes with your own sprites for a fuller remake. Have fun & happy flapping! 🐤