ChatGPT
A chicken crossing the road—with a very good reason.
🌳 │ │ 🌳 │ ┆ │ │ ┆ │ 🐔 → ░░░░░░░░░░░ → 🐛 │ ┆ │ │ ┆ │ 🌼 │ │ 🌼 🌤️ 🌳 🌳 🌳
══════════════════════════════════════════ SIDEWALK══════════════════════════════════════════ 🐔 ──► ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ (road) ══════════════════════════════════════════ OTHER SIDE ✨ (the grass is greener) ✨══════════════════════════════════════════Frame 1: 🐔 . . . . . . . . . . 🚗Frame 2: . . 🐔 . . . . . . 🚗 . .Frame 3: . . . . 🐔 . . . 🚗 . . .Frame 4: . . . . . . 🐔 🚗 . . . . (!!)Frame 5: . . . . . . . 🐔💨🚗 . . . (a close one)Frame 6: . . . . . . . . . 🐔 . . . 🚗Frame 7: . . . . . . . . . . . 🐔 ✅SIDE A THE ROAD SIDE B(Boring farm) (Endless Corn) 🌾 | 🚗💨 | | 🌽 🐔 ➡️ | | 🚙💨 | 🌽 🌾 | 🚚💨 | | 🌽-------------------------+------------+-------------+-------------------------<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Cross the Road!</title> <style> body { margin: 0; background: #1e293b; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; font-family: system-ui, -apple-system, sans-serif; color: #fff; } h1 { margin-bottom: 6px; font-size: 1.5rem; } p { margin: 0 0 12px 0; color: #94a3b8; font-size: 0.9rem; } canvas { border: 4px solid #334155; border-radius: 12px; background: #334155; box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5); } .keys { margin-top: 10px; font-size: 0.85rem; color: #cbd5e1; } kbd { background: #475569; padding: 3px 7px; border-radius: 4px; border-bottom: 2px solid #0f172a; } </style></head><body> <h1>🐔 Why did the chicken cross the road?</h1> <p>Help it find out! Dodge the cars to reach the other side.</p> <canvas id="game" width="400" height="500"></canvas> <div class="keys">Use <kbd>↑</kbd> <kbd>↓</kbd> <kbd>←</kbd> <kbd>→</kbd> or <kbd>W</kbd><kbd>A</kbd><kbd>S</kbd><kbd>D</kbd> to move</div>
<script> const canvas = document.getElementById('game'); const ctx = canvas.getContext('2d');
const PUNCHLINES = [ "To prove to the opossum that it could actually be done!", "Because it saw a greener pasture (and free corn)!", "To escape the Colonel!", "No reason. It just felt like walking.", "To get to the other side... literally!" ];
const LANE_HEIGHT = 60; let chicken = { x: 185, y: 440, size: 28, speed: 20 }; let gameState = 'playing'; // 'playing', 'won', 'lost' let message = '';
// Lanes: y position, speed, car frequency, car emoji const lanes = [ { y: 80, speed: 2.5, cars: [], emoji: '🚗', dir: 1, width: 45 }, { y: 150, speed: -3.2, cars: [], emoji: '🏎️', dir: -1, width: 45 }, { y: 220, speed: 1.8, cars: [], emoji: '🚚', dir: 1, width: 60 }, { y: 290, speed: -2.2, cars: [], emoji: '🚙', dir: -1, width: 45 }, { y: 360, speed: 3.8, cars: [], emoji: '🚕', dir: 1, width: 45 } ];
function spawnCar(lane) { const x = lane.dir === 1 ? -lane.width : canvas.width + 10; lane.cars.push({ x, y: lane.y }); }
// Initialize initial cars lanes.forEach(l => { spawnCar(l); l.cars[0].x = Math.random() * (canvas.width - 50); });
function resetChicken() { chicken.x = 185; chicken.y = 440; }
// Input handlers window.addEventListener('keydown', (e) => { if (gameState !== 'playing') { if (e.key === ' ' || e.key === 'Enter') { gameState = 'playing'; resetChicken(); } return; }
if (e.key === 'ArrowUp' || e.key === 'w') chicken.y -= chicken.speed; if (e.key === 'ArrowDown' || e.key === 's') chicken.y += chicken.speed; if (e.key === 'ArrowLeft' || e.key === 'a') chicken.x -= chicken.speed; if (e.key === 'ArrowRight' || e.key === 'd') chicken.x += chicken.speed;
// Keep inside horizontal bounds chicken.x = Math.max(10, Math.min(canvas.width - chicken.size - 10, chicken.x)); chicken.y = Math.min(440, chicken.y);
// Check win condition (reached other side) if (chicken.y <= 40) { gameState = 'won'; message = PUNCHLINES[Math.floor(Math.random() * PUNCHLINES.length)]; } });
function update() { if (gameState !== 'playing') return;
lanes.forEach(lane => { // Move existing cars lane.cars.forEach(car => { car.x += lane.speed;
// Simple AABB Collision if ( chicken.x < car.x + lane.width - 8 && chicken.x + chicken.size > car.x + 8 && chicken.y < car.y + 20 && chicken.y + chicken.size > car.y - 15 ) { gameState = 'lost'; message = "Squawk! You became roadkill. Press SPACE to retry."; } });
// Remove offscreen cars lane.cars = lane.cars.filter(c => lane.dir === 1 ? c.x < canvas.width + 100 : c.x > -100);
// Spawn new cars periodically if (lane.cars.length < 3 && Math.random() < 0.015) { spawnCar(lane); } }); }
function draw() { ctx.clearRect(0, 0, canvas.width, canvas.height);
// 1. Draw Zones // Finish Grass ctx.fillStyle = '#16a34a'; ctx.fillRect(0, 0, canvas.width, 70);
// Roads ctx.fillStyle = '#1e293b'; ctx.fillRect(0, 70, canvas.width, 360);
// Lane dividers ctx.strokeStyle = '#475569'; ctx.setLineDash([15, 15]); for (let y = 140; y <= 350; y += 70) { ctx.beginPath(); ctx.moveTo(0, y); ctx.lineTo(canvas.width, y); ctx.stroke(); } ctx.setLineDash([]);
// Starting Grass ctx.fillStyle = '#16a34a'; ctx.fillRect(0, 430, canvas.width, 70);
// Finish decorations (corn / barns) ctx.font = '22px sans-serif'; ctx.fillText('🌽 🌾 🌽 🏡 🌽 🌾 🌽', 30, 40);
// 2. Draw Cars lanes.forEach(lane => { ctx.font = '32px sans-serif'; lane.cars.forEach(car => { ctx.save(); if (lane.dir === -1) { ctx.scale(-1, 1); ctx.fillText(lane.emoji, -car.x - lane.width, car.y + 20); } else { ctx.fillText(lane.emoji, car.x, car.y + 20); } ctx.restore(); }); });
// 3. Draw Chicken ctx.font = '28px sans-serif'; ctx.fillText('🐔', chicken.x, chicken.y + 20);
// 4. Overlays (Game Over / Victory) if (gameState !== 'playing') { ctx.fillStyle = 'rgba(15, 23, 42, 0.85)'; ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = '#fff'; ctx.textAlign = 'center';
if (gameState === 'won') { ctx.font = 'bold 24px sans-serif'; ctx.fillText('🎉 You Made It!', canvas.width / 2, 200);
ctx.font = '15px sans-serif'; ctx.fillStyle = '#fde047'; wrapText(ctx, `"${message}"`, canvas.width / 2, 240, 320, 22);
ctx.fillStyle = '#94a3b8'; ctx.font = '13px sans-serif'; ctx.fillText('Press SPACE to cross again', canvas.width / 2, 320); } else { ctx.font = 'bold 24px sans-serif'; ctx.fillStyle = '#ef4444'; ctx.fillText('💥 CRASH!', canvas.width / 2, 210);
ctx.font = '14px sans-serif'; ctx.fillStyle = '#cbd5e1'; ctx.fillText(message, canvas.width / 2, 250); } ctx.textAlign = 'start'; } }
function wrapText(context, text, x, y, maxWidth, lineHeight) { const words = text.split(' '); let line = ''; for (let n = 0; n < words.length; n++) { const testLine = line + words[n] + ' '; const metrics = context.measureText(testLine); if (metrics.width > maxWidth && n > 0) { context.fillText(line, x, y); line = words[n] + ' '; y += lineHeight; } else { line = testLine; } } context.fillText(line, x, y); }
function loop() { update(); draw(); requestAnimationFrame(loop); }
loop(); </script></body></html> ___ __/ \__ <( o o )> \ ^ / ||||||| / \ / ROAD \ =============