Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

chore(demo): remove unused Flappy Bird file

thinhlpg2d306503fb0e
diff --git a/flappy.html b/flappy.html
deleted file mode 100644
index e612a9794..000000000
--- a/flappy.html
+++ /dev/null
@@ -1,162 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
-<meta charset="utf-8">
-<meta name="viewport" content="width=device-width, initial-scale=1">
-<title>Flappy Bird</title>
-<style>
- html,body{height:100%;margin:0;background:#1a1a2e;display:flex;align-items:center;justify-content:center;font-family:system-ui,-apple-system,sans-serif;}
- #wrap{position:relative;}
- canvas{display:block;border-radius:12px;box-shadow:0 12px 40px rgba(0,0,0,.5);touch-action:none;}
- #hint{position:absolute;left:0;right:0;bottom:-28px;text-align:center;color:#8a8aa3;font-size:13px;}
-</style>
-</head>
-<body>
-<div id="wrap">
- <canvas id="c" width="400" height="600"></canvas>
- <div id="hint">Click / Tap / Space to flap &nbsp;·&nbsp; R to restart</div>
-</div>
-<script>
-const c = document.getElementById('c'), x = c.getContext('2d');
-const W = c.width, H = c.height;
-const GROUND = 80, GRAV = 0.45, FLAP = -7.6, GAP = 150, PIPE_W = 62, SPEED = 2.4;
-
-let bird, pipes, score, best = +(localStorage.getItem('flappyBest')||0), state, frame, groundX;
-
-function reset(){
- bird = {x:110, y:H/2-40, v:0, r:13, rot:0};
- pipes = []; score = 0; frame = 0; groundX = 0; state = 'ready';
-}
-reset();
-
-function spawnPipe(){
- const margin = 60;
- const top = margin + Math.random()*(H-GROUND-GAP-margin*2);
- pipes.push({x:W, top, scored:false});
-}
-
-function flap(){
- if(state==='ready'){ state='play'; }
- if(state==='play'){ bird.v = FLAP; }
- else if(state==='over'){ reset(); }
-}
-
-function update(){
- if(state==='ready'){ bird.y = H/2-40 + Math.sin(frame/18)*6; groundX=(groundX-SPEED)%24; frame++; return; }
- if(state==='over'){
- bird.v += GRAV; bird.y += bird.v;
- if(bird.y > H-GROUND-bird.r){ bird.y = H-GROUND-bird.r; bird.v=0; }
- bird.rot = Math.min(bird.rot+0.08, 1.6);
- return;
- }
- frame++; groundX = (groundX - SPEED) % 24;
- bird.v += GRAV; bird.y += bird.v;
- bird.rot = Math.max(-0.5, Math.min(bird.v/12, 1.6));
-
- if(frame % 95 === 0 || pipes.length===0) spawnPipe();
- for(const p of pipes) p.x -= SPEED;
- pipes = pipes.filter(p => p.x + PIPE_W > -10);
-
- for(const p of pipes){
- if(!p.scored && p.x + PIPE_W < bird.x){ p.scored = true; score++; }
- const inX = bird.x + bird.r > p.x && bird.x - bird.r < p.x + PIPE_W;
- if(inX && (bird.y - bird.r < p.top || bird.y + bird.r > p.top + GAP)) die();
- }
- if(bird.y + bird.r >= H-GROUND){ bird.y = H-GROUND-bird.r; die(); }
- if(bird.y - bird.r < 0){ bird.y = bird.r; bird.v = 0; }
-}
-
-function die(){
- if(state!=='play') return;
- state='over';
- if(score > best){ best = score; localStorage.setItem('flappyBest', best); }
-}
-
-function pipe(p){
- const g = x.createLinearGradient(p.x,0,p.x+PIPE_W,0);
- g.addColorStop(0,'#4ea832'); g.addColorStop(.35,'#7ed957'); g.addColorStop(1,'#3d8226');
- x.fillStyle = g; x.strokeStyle='#2c5c1c'; x.lineWidth=2;
- const lip = 16;
- // top
- x.fillRect(p.x, 0, PIPE_W, p.top - lip);
- x.strokeRect(p.x, 0, PIPE_W, p.top - lip);
- x.fillRect(p.x-5, p.top-lip, PIPE_W+10, lip);
- x.strokeRect(p.x-5, p.top-lip, PIPE_W+10, lip);
- // bottom
- const by = p.top + GAP;
- x.fillRect(p.x-5, by, PIPE_W+10, lip);
- x.strokeRect(p.x-5, by, PIPE_W+10, lip);
- x.fillRect(p.x, by+lip, PIPE_W, H-GROUND-by-lip);
- x.strokeRect(p.x, by+lip, PIPE_W, H-GROUND-by-lip);
-}
-
-function drawBird(){
- x.save();
- x.translate(bird.x, bird.y); x.rotate(bird.rot);
- x.fillStyle='#ffd93b'; x.strokeStyle='#c9a227'; x.lineWidth=2;
- x.beginPath(); x.ellipse(0,0,15,12,0,0,7); x.fill(); x.stroke();
- // wing
- x.fillStyle='#fff3c4';
- const w = state==='play' ? Math.sin(frame/3)*4 : 0;
- x.beginPath(); x.ellipse(-3,2+w,8,5,0,0,7); x.fill(); x.stroke();
- // eye
- x.fillStyle='#fff'; x.beginPath(); x.arc(6,-4,4.5,0,7); x.fill(); x.stroke();
- x.fillStyle='#000'; x.beginPath(); x.arc(7.5,-4,2,0,7); x.fill();
- // beak
- x.fillStyle='#ff8c25'; x.beginPath();
- x.moveTo(13,0); x.lineTo(22,2); x.lineTo(13,6); x.closePath(); x.fill(); x.stroke();
- x.restore();
-}
-
-function text(t, y, size, color){
- x.font = `bold ${size}px system-ui, sans-serif`;
- x.textAlign='center'; x.lineWidth=6; x.strokeStyle='rgba(0,0,0,.45)';
- x.strokeText(t, W/2, y); x.fillStyle=color; x.fillText(t, W/2, y);
-}
-
-function draw(){
- // sky
- const sky = x.createLinearGradient(0,0,0,H);
- sky.addColorStop(0,'#4ec0ca'); sky.addColorStop(1,'#a8e6cf');
- x.fillStyle=sky; x.fillRect(0,0,W,H);
- // clouds
- x.fillStyle='rgba(255,255,255,.5)';
- for(let i=0;i<4;i++){
- const cx = ((i*140 + frame*0.3) % (W+120)) - 60, cy = 70 + i*47;
- x.beginPath(); x.arc(cx,cy,24,0,7); x.arc(cx+24,cy+6,18,0,7); x.arc(cx-22,cy+8,16,0,7); x.fill();
- }
- pipes.forEach(pipe);
- drawBird();
- // ground
- x.fillStyle='#ded895'; x.fillRect(0,H-GROUND,W,GROUND);
- x.fillStyle='#5fa832'; x.fillRect(0,H-GROUND,W,14);
- x.fillStyle='#4c8a28';
- for(let i=-1;i<W/24+2;i++) x.fillRect(i*24+groundX, H-GROUND+14, 12, 6);
-
- text(score, 88, 46, '#fff');
-
- if(state==='ready'){
- text('FLAPPY BIRD', H/2-90, 34, '#fff');
- text('click to start', H/2-50, 18, '#fff');
- }
- if(state==='over'){
- x.fillStyle='rgba(0,0,0,.35)'; x.fillRect(0,0,W,H);
- text('GAME OVER', H/2-60, 40, '#ffd93b');
- text('Score: '+score, H/2-10, 24, '#fff');
- text('Best: '+best, H/2+24, 24, '#fff');
- text('click or press R to retry', H/2+70, 16, '#fff');
- }
-}
-
-function loop(){ update(); draw(); requestAnimationFrame(loop); }
-loop();
-
-addEventListener('keydown', e => {
- if(e.code==='Space' || e.code==='ArrowUp'){ e.preventDefault(); flap(); }
- if(e.key==='r' || e.key==='R') reset();
-});
-c.addEventListener('mousedown', e => { e.preventDefault(); flap(); });
-c.addEventListener('touchstart', e => { e.preventDefault(); flap(); }, {passive:false});
-</script>
-</body>
-</html>