commit f2eec57b5e8a8ae128ef67131d70748ffd70ee61 Author: hermes Date: Sat Dec 5 23:17:21 2026 +0000 Advent of AI Slop Day 5: Pelican on a Bike Endless winter-city ride: pelican on a bicycle or reindeer on a unicycle, procedural canvas skyline, garlands to duck, snowmen to hop, fish to hoard. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d4c928e --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +node_modules +dist +*.tsbuildinfo +preview_shot.png diff --git a/README.md b/README.md new file mode 100644 index 0000000..b806b38 --- /dev/null +++ b/README.md @@ -0,0 +1,40 @@ +# Advent of AI Slop — Day 5: Pelican on a Bike + +> Task: *Create a game with a pelican on a bike riding your city. Or maybe a reindeer on a unicycle?* + +Both. Obviously. + +An endless side-scroll ride through a procedurally drawn winter city at dusk: +a **pelican on a bicycle** (one big flap-jump) or a **reindeer on a unicycle** +(double jump, Rudolph nose). Hop the snowmen, duck under the Christmas +garlands, don't flat-spot yourself in a pothole, and collect the fish — they +are for later. + +## Play + +**Live:** https://pages.obahan.xyz/lullu/advent-of-slop-05-pelican-on-a-bike/ + +- `Space` / `↑` / `W` / tap — jump (reindeer: press again mid-air to double-jump) +- `↓` / `S` — duck (required under garlands; hold in the air to slam down) +- `P` / `Esc` — pause · `R` — restart · `1`/`2` — pick rider + +Best score per rider is kept in `localStorage`. + +## Build + +Vite + TypeScript, no dependencies beyond the template, no images — every +pixel (skyline, snowmen, pelican, antlers) is drawn with canvas paths. + +```sh +pnpm install +pnpm build # tsc + vite build +``` + +`dist/` is published to the `pages` branch and served at the URL above. + +## Layout + +- `src/art.ts` — all canvas drawing (city parallax, obstacles, riders) +- `src/game.ts` — physics, spawning, collisions, state machine +- `src/main.ts` — DOM wiring, input, HUD, overlays +- `scripts/smoke5.py` — headless Playwright smoke test of the built site diff --git a/index.html b/index.html new file mode 100644 index 0000000..ba8eb5d --- /dev/null +++ b/index.html @@ -0,0 +1,71 @@ + + + + + + + Pelican on a Bike — Advent of AI Slop Day 5 + + + + + + + + + + + + + +
+
+

Pelican on a Bike

+

an endless ride through a very Danish winter city

+
+
+ score 0 + distance 0 m + speed 0 km/t + fish 0 + best 0 +
+
+ + + + +
+

jump the snowmen · duck under the garlands · the fish are for later

+
+ + diff --git a/package.json b/package.json new file mode 100644 index 0000000..8de90c5 --- /dev/null +++ b/package.json @@ -0,0 +1,15 @@ +{ + "name": "advent-of-slop-entry", + "type": "module", + "private": true, + "scripts": { + "dev": "vite", + "build": "tsc && vite build", + "preview": "vite preview" + }, + "packageManager": "pnpm@11.5.2", + "devDependencies": { + "typescript": "^7.0.2", + "vite": "^8.3.8" + } +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml new file mode 100644 index 0000000..e13864f --- /dev/null +++ b/pnpm-lock.yaml @@ -0,0 +1,717 @@ +lockfileVersion: '9.0' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + +importers: + + .: + devDependencies: + typescript: + specifier: ^7.0.2 + version: 7.0.2 + vite: + specifier: ^8.3.8 + version: 8.3.8 + +packages: + + '@emnapi/core@2.0.0-beta.2': + resolution: {integrity: sha512-MzCVoWtcg4Pm2B3je5mMvYMvj3MmBKw+fU7vbsJc9/iT8ip6/eYIHo/Dsm/mr+wsHB6SEyJDuxB09Yy6r/8+4A==} + + '@emnapi/runtime@2.0.0-beta.2': + resolution: {integrity: sha512-JcrSPzPvZuNZvJqPTF9Fw25LbOJ8avzFVlaf2grmH4Cku0oGP47tRgqPZadcfj3YoZMHkFVnCYFbQM8I+i5QEw==} + + '@emnapi/wasi-threads@2.2.0': + resolution: {integrity: sha512-JP7OYH38Q7+pyTAe14raZHLQIK7BDKbdwji+Xi3pcd/6QkJYQH3SX4wu6EplGrGJWRepoNzedfm0G3B9Z4e9Rw==} + + '@napi-rs/wasm-runtime@1.2.6': + resolution: {integrity: sha512-mRyDmEw9/fCDXCGfL1sbgIw/GUK0PVxRW4YwgPN61F3LQ+fSyoBFarJVzgGyhF6kRzEQZ0FejDqm4WLXSeqQmw==} + engines: {node: ^20.19.0 || ^22.13.0 || >=23.5.0} + peerDependencies: + '@emnapi/core': ^1.7.1 || 2.0.0-beta.2 + '@emnapi/runtime': ^1.7.1 || 2.0.0-beta.2 + + '@oxc-project/types@0.156.0': + resolution: {integrity: sha512-1Duyg48TdJNdyhEB8Xn1L36bT9Pv6GUtlKjHxOys8xkaF/rQq3XJE+bAurSK/AgIz5mGFsb77cn9Pb20+WCScw==} + + '@rolldown/binding-android-arm-eabi@1.2.19': + resolution: {integrity: sha512-e+Ebe0WT+9tbXmNKPIiC8YrWAHYwug3m6i4p3rZGGulfZri1jtI4HslT+OZnFf/OIHowWF71DTlHwXBP2SiA7A==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [android] + + '@rolldown/binding-android-arm64@1.2.19': + resolution: {integrity: sha512-hOombrTJ+szt2ciEzS7oCA78lMPBgF5UMQWCJIyNfnrI7GLl8HYoFqCnpL2gcPOaXMqryGCU5ExdQKyDDcC+yA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [android] + + '@rolldown/binding-darwin-arm64@1.2.19': + resolution: {integrity: sha512-XoMA2pwCKGTQzUjPgtRwkedH4WmXhdIPKT6l6oOxd1PUbNodGI6DcBekgN7EC//+x3pfBYX/qL1gNmZAqivw5g==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [darwin] + + '@rolldown/binding-darwin-x64@1.2.19': + resolution: {integrity: sha512-zo8EsSSwMZCY/e+fRnGaX02YGgvJD0yvhNi/9hpGPA2MJ9ZF8dPCw75UGfpI6OpQ/myR/dIYmogRvqiZD0TrXg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [darwin] + + '@rolldown/binding-freebsd-x64@1.2.19': + resolution: {integrity: sha512-O8ISAOfI1nj7AuBPd30FSF47z7f7lzlk5poQVGgiikvQuGEBFYvW8ki+UEnT+YJPnNGjQzn304klt4O9FUE7mA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [freebsd] + + '@rolldown/binding-linux-arm-gnueabihf@1.2.19': + resolution: {integrity: sha512-/lYCba5NO0yq4S0jGMH8QTBtkvQxoXjoQWzF5BcWp9MjB9jxVRD1GQDNofkVjcOj30DWyhLIN/4Oe60JKzaONw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [linux] + + '@rolldown/binding-linux-arm64-gnu@1.2.19': + resolution: {integrity: sha512-pm/apFMBnSbFb3O6nG5pHO1iqHhZrjGDFEjSm+ot9J17XXPvH9L90y5h+jgfHCE+Qdlsvy8qKEcU4VKxgjD+vA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-arm64-musl@1.2.19': + resolution: {integrity: sha512-K1SmQp3FFichn8oqrNIwvFoZ5wcvjC7goBzpaMNvLf9FZc+QB/QvLmnpJZgAAGHiD980tP8FZZnXk2K94rvlxg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + libc: [musl] + + '@rolldown/binding-linux-ppc64-gnu@1.2.19': + resolution: {integrity: sha512-I0xwD57jP/3A7+5UPZin2w8Y7XHEmEM5zqpYZOcQ45MlNW6tUJUziymV3yRr7rL4vwyfEcRsRksC4a7Kc08p5Q==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [ppc64] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-s390x-gnu@1.2.19': + resolution: {integrity: sha512-BrtEHT24SNXj9HiXqy+s/kXiSiQGt6EKCPUlRirAoIioVxKGnbXBUEkbZASAei7iZJB0/Ynm+0JP00Ipx7AnSw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [s390x] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-x64-gnu@1.2.19': + resolution: {integrity: sha512-rm75/9DkHKeU2WnA8w4X94WGYgLlDCFCfkQC+4bguVJmC/jvDRv2B+2wLOYhyE0fVuv7//Ckk39OoOufyCu76Q==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-x64-musl@1.2.19': + resolution: {integrity: sha512-irh/4+iYFM4GAzpluDErgjz89bj6NDtqqMAG/6O1LG38Ed3NpyebzCpcVNkFW8uhy+/3/BocUvnXDR33CXWe9A==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + libc: [musl] + + '@rolldown/binding-openharmony-arm64@1.2.19': + resolution: {integrity: sha512-+KWTWNoPt+CfSq94CiceWu3yPE+QzkaG+phPyz9G60tmZLwfQkcA4AeksafzvJAw4pvg1mcd5a1TkUqVv0s4JA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [openharmony] + + '@rolldown/binding-wasm32-wasi@1.2.19': + resolution: {integrity: sha512-7EH+skOsl5qpWnK0vzamgJFhOv1cwxQpsxm8tI883K9fur5c27p8q87fzEO6BbBPabA2/+s/zR63/pLc137iOg==} + engines: {node: ^20.19.0 || ^22.13.0 || >=23.5.0} + cpu: [wasm32] + + '@rolldown/binding-win32-arm64-msvc@1.2.19': + resolution: {integrity: sha512-3Q1Yg1Q7tEvBWoZf5rFvG/GKZQPgwfru+p4wBajDfJFBs0SHCpL++dfTjW9gyAKd1T7ZpIYvdaUax7Pa/IhFVQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [win32] + + '@rolldown/binding-win32-x64-msvc@1.2.19': + resolution: {integrity: sha512-y/sqRRc6d7hECzOFc5n3LSeqctmIp9mMjY1Kq4s14uLPd/LZ4z7i1zrW6fMtp2mPeuQIC4e6ULMcwQzMomqQag==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [win32] + + '@rolldown/pluginutils@1.1.1': + resolution: {integrity: sha512-glFIJDvLNDtJhT9qrMFWLPbvS+skxgt4L0K8Ei2YtnhPysAJnsI7nyxSJxKj4ADeKX0OLjC4ntRkwpLOoS3rwA==} + + '@tybys/wasm-util@0.10.5': + resolution: {integrity: sha512-dOGOPxlaNV+G046mZzN+9C0dAcQZeSKcXiVaM0TYy/LM4ttTmgSBDxYfovcYI8Em3+eAbiAYpvWLOv8+ZVRJKA==} + + '@typescript/typescript-aix-ppc64@7.0.2': + resolution: {integrity: sha512-MTKKkWB7p/0E9xi1d1tHtZ5PiLkGEMIq88pK2CubZjOsLtYTLqhgIgi6zepFa+9GHZ6h05NMCkQxGKiPXMxXtQ==} + engines: {node: '>=16.20.0'} + cpu: [ppc64] + os: [aix] + + '@typescript/typescript-darwin-arm64@7.0.2': + resolution: {integrity: sha512-gowzar9MwS/aRWp6f3a4KUqzRjAZjOsmGNCM6LcTgXum+dBfgsBVMN+AgvOCCbguXyick6LJhpBszxMebJ8syA==} + engines: {node: '>=16.20.0'} + cpu: [arm64] + os: [darwin] + + '@typescript/typescript-darwin-x64@7.0.2': + resolution: {integrity: sha512-SZ9xZInqApNlNGc9s0W1VSsktYSOe9cFqNOIqmN1Gs8SmkjKZYFt017G4VwPxASInODuAdbTW7sXiFUf893RgA==} + engines: {node: '>=16.20.0'} + cpu: [x64] + os: [darwin] + + '@typescript/typescript-freebsd-arm64@7.0.2': + resolution: {integrity: sha512-W5NH4y/J0plIIS5b2xvTEkU7JFxyqdMAOgf+Ilhl0vHQXKO5dZoxd+C/jEtq56c4F3wk71RB4BMRQ2XdI+bwYQ==} + engines: {node: '>=16.20.0'} + cpu: [arm64] + os: [freebsd] + + '@typescript/typescript-freebsd-x64@7.0.2': + resolution: {integrity: sha512-UMGDx5sTpzNw3WiPebH7l90IWfJggEd+egHt/q6p7/Cm3zqoV7VxkGXt+3DxPIw8CcmvAB0j3sVVfbhX+M4Tpw==} + engines: {node: '>=16.20.0'} + cpu: [x64] + os: [freebsd] + + '@typescript/typescript-linux-arm64@7.0.2': + resolution: {integrity: sha512-Qh4eU4/y3yDjnfjjyPYihMj5/ODIlmt+Bzu17OI+fiSRDW57QmU5SiN63exPRNJPKUzcc1INa1NXdrJ+MqHjUQ==} + engines: {node: '>=16.20.0'} + cpu: [arm64] + os: [linux] + + '@typescript/typescript-linux-arm@7.0.2': + resolution: {integrity: sha512-gffT3xPz9sR7j/YJExkyPntrI0P2EP9XbOyWzth2/Gs0RstK+90RBcO0ncXoXy/beYll1SXw846Nf2zdnEz0QQ==} + engines: {node: '>=16.20.0'} + cpu: [arm] + os: [linux] + + '@typescript/typescript-linux-loong64@7.0.2': + resolution: {integrity: sha512-uEHck9i8hoAzXPiYRib1O7miOnz23SxIeVl6F4LXox+qov1K35jHcEW6VHKvZI+pyvl7fZEP4MCU5LYvIq1GuQ==} + engines: {node: '>=16.20.0'} + cpu: [loong64] + os: [linux] + + '@typescript/typescript-linux-mips64el@7.0.2': + resolution: {integrity: sha512-R4KvAMnE43W5Qeqb0Ly56O3mWMWIAgsMyz36DCaycd5nbg/9kzm0liw3JocfRqyJY0KPmzFjbswozXyW0DnIYA==} + engines: {node: '>=16.20.0'} + cpu: [mips64el] + os: [linux] + + '@typescript/typescript-linux-ppc64@7.0.2': + resolution: {integrity: sha512-DORx5b3sd/4S7eayxm4FQv+A7CrkUIGRaHiwI8oiHTAI1fAPWhF4J0vAlkC8biAlHSVVwxMQ3tjZ2/DVbnQiiA==} + engines: {node: '>=16.20.0'} + cpu: [ppc64] + os: [linux] + + '@typescript/typescript-linux-riscv64@7.0.2': + resolution: {integrity: sha512-wf0jqEDOjrPRnKwYRyyJDRo11KMbvMFrU+q4zqKyChODBzvlkbhNQfKvLxQCcwTpdDaXSHZTVuh0JoCrKCUMHQ==} + engines: {node: '>=16.20.0'} + cpu: [riscv64] + os: [linux] + + '@typescript/typescript-linux-s390x@7.0.2': + resolution: {integrity: sha512-IkwJc3L7yhytWd/ewjyxNDfOmswCm9GWMJT/ue/dU4aZNbwZeYAetq42VyLmsmSjvoX7z74X6ZaYCtzAr0EuGw==} + engines: {node: '>=16.20.0'} + cpu: [s390x] + os: [linux] + + '@typescript/typescript-linux-x64@7.0.2': + resolution: {integrity: sha512-EYdf2cNg7rgCWJnxCdJ+F3V39O8ihb37eHAu1LK8oAFizgTQbPOK7zHHXbPt8rX24COqODXeI3sIf0fCXG7H/A==} + engines: {node: '>=16.20.0'} + cpu: [x64] + os: [linux] + + '@typescript/typescript-netbsd-arm64@7.0.2': + resolution: {integrity: sha512-+polYF4MF04aPpO5FTkHran9yUQDSXqy5GiSDKpsll5jy3l3+g9QLhpf39T+ePtefhXLOGrLl0QIjkQP6VnelA==} + engines: {node: '>=16.20.0'} + cpu: [arm64] + os: [netbsd] + + '@typescript/typescript-netbsd-x64@7.0.2': + resolution: {integrity: sha512-8YIT0EHM/3dq10ZOVF/A7pc/YSMtbcecct4rWtexrnSCHOPcpC2KTLXfTCR6vDpnSiY12heNb1GiN/wu+T/FyA==} + engines: {node: '>=16.20.0'} + cpu: [x64] + os: [netbsd] + + '@typescript/typescript-openbsd-arm64@7.0.2': + resolution: {integrity: sha512-APT8+ClYnuYm1u9+kgGXoMj2VzWzcymwh2gNSQVySHfkRDGOTVkoWLjCmOQSaO+PoqQ57B0flRp9SA+7GnnkzQ==} + engines: {node: '>=16.20.0'} + cpu: [arm64] + os: [openbsd] + + '@typescript/typescript-openbsd-x64@7.0.2': + resolution: {integrity: sha512-yX7s+Q0Dln0Dt9tEzZsAjXXR/+ytBM7AlglaqyeMPxQszJ1JhlJdZ6jLA+IzldHtflX81em7lDao1xXu+aRRkg==} + engines: {node: '>=16.20.0'} + cpu: [x64] + os: [openbsd] + + '@typescript/typescript-sunos-x64@7.0.2': + resolution: {integrity: sha512-dLJDGaLZ1D4HPQn62u1n8mBDkJREwMsAkCdkwd4Ieqw+x3TUyTsqY0YiBCtE6H6OzzgGk3iuZ3vFWRS+E8/d1g==} + engines: {node: '>=16.20.0'} + cpu: [x64] + os: [sunos] + + '@typescript/typescript-win32-arm64@7.0.2': + resolution: {integrity: sha512-Gyl1Vy6OsWesLzmq+EP0Fb7b4Nid5232AvcA2SFcdYreldpNtYFFofPjnt62y9hQy7VTaZp65ICJjuAQRaVcIQ==} + engines: {node: '>=16.20.0'} + cpu: [arm64] + os: [win32] + + '@typescript/typescript-win32-x64@7.0.2': + resolution: {integrity: sha512-0BQ3HkAHHlKLSp1qRvf3SUhGpGsDuhB/jgFw75guyqbxJqEaS0Cw/VFO8i2nHglJUzQCRtMMR/IBAKE3ETMC4g==} + engines: {node: '>=16.20.0'} + cpu: [x64] + os: [win32] + + detect-libc@2.1.2: + resolution: {integrity: sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==} + engines: {node: '>=8'} + + fdir@6.5.0: + resolution: {integrity: sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==} + engines: {node: '>=12.0.0'} + peerDependencies: + picomatch: ^3 || ^4 + peerDependenciesMeta: + picomatch: + optional: true + + fsevents@2.3.3: + resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} + engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} + os: [darwin] + + lightningcss-android-arm64@1.33.0: + resolution: {integrity: sha512-gEpRTalKdosp4Bb8qWtc2iOgE5SeIHlpS1up9bFq2wAyYhl1UdTObYiHe98zEM9SQvSoqQZ1IQD0JNpg3Ml5pg==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [android] + + lightningcss-darwin-arm64@1.33.0: + resolution: {integrity: sha512-Sciaz8eenNTKn9b3t7+xr0ipTp9YxKQY4npwQ3mrRuL0BAVHBLyZxofhaKBAVtzmtRZ/zTyo0/to4B1uWG/Djg==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [darwin] + + lightningcss-darwin-x64@1.33.0: + resolution: {integrity: sha512-Z5UPAxzrjlWNNyGy6i65cJzzvgJ5D3T6wMvs+gWpY9d7qRhANrxqAp6LhxIgZhWEw18RfJTGcRxjuLIBr+m8XQ==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [darwin] + + lightningcss-freebsd-x64@1.33.0: + resolution: {integrity: sha512-QQM/Ti/hQajJwCY+RiWuCZ9sdtI/XQk7nDK5vC8kkdwixezOlDgvDx7+RT+QjK6FcFT4MpsuoBnHIo/O3StRRg==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [freebsd] + + lightningcss-linux-arm-gnueabihf@1.33.0: + resolution: {integrity: sha512-N7FVBe6iS24MlM6R/4RBTxGhQheZGs7tiQ9U32UtF75NzP5Q7xWPRqLBCKxlRQRk3rY1jCIPLzx7WzOhuUIRLQ==} + engines: {node: '>= 12.0.0'} + cpu: [arm] + os: [linux] + + lightningcss-linux-arm64-gnu@1.33.0: + resolution: {integrity: sha512-j2v/itmy4HlNxlc6voKXYgBqNi0Ng2LShg4z7GufpEgs05P+2suBVyi9I6YHq5uoVFx9ETin3eCEhLVyXGQnKg==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [linux] + libc: [glibc] + + lightningcss-linux-arm64-musl@1.33.0: + resolution: {integrity: sha512-yiO5ROMuYQgXbC60yjZU5CYSFZGKXL0HFATXt9mHJn1+zW55oCtMI9NfcVhYLMFDL7gV7oBPon/EmMMGg2OvtQ==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [linux] + libc: [musl] + + lightningcss-linux-x64-gnu@1.33.0: + resolution: {integrity: sha512-ar+Ju7LmcN0Jo4FpL4hpFybwNG9/3A/Br5KW2n2jyODg3MEZXaDYADdemoNS+BDNfMgKvylJLj4S5tyRActuAg==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [linux] + libc: [glibc] + + lightningcss-linux-x64-musl@1.33.0: + resolution: {integrity: sha512-RYiYbkokw0trfKqqzfF55lginwEPrD3OJDfTuJzFs1MK6iFnDenaz1fqLLtX4ITG3OktJQXOeTaw1awrBAlZPw==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [linux] + libc: [musl] + + lightningcss-win32-arm64-msvc@1.33.0: + resolution: {integrity: sha512-1K+MPfLSFVpphzpdbfkhlWk6wBrTObBzS2T6db10PNOZgR9GoVsAWzwNyuhUYYbTp23j+4RrncfujZ4uAzXvwA==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [win32] + + lightningcss-win32-x64-msvc@1.33.0: + resolution: {integrity: sha512-OlEICDx/Xl0FqSp4bry8zFnCvGpig3Gl4gCquvYwHuqJKEC1+n9NgDniFvqHGmMv1ZkqDJrDqKKSykTDX+ehuA==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [win32] + + lightningcss@1.33.0: + resolution: {integrity: sha512-WkUDrojuJs0xkgGf2udWxa3yGBRxPtxUkB79i6aCZLRgc7PM8fZe9TosfPDcvEpQZbuFASnHYmRLBLUbmLOIIA==} + engines: {node: '>= 12.0.0'} + + nanoid@3.3.20: + resolution: {integrity: sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ==} + engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} + hasBin: true + + picocolors@1.1.1: + resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==} + + picomatch@4.0.7: + resolution: {integrity: sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==} + engines: {node: '>=12'} + + postcss@8.5.33: + resolution: {integrity: sha512-RVHEU9/Pp1Fnjr/MpAJsZoADukCKhfIi15OunEYiGktIkYLkPVvC1sioWolGDS7XByMTx9m/IGbro0Js13zhnQ==} + engines: {node: ^10 || ^12 || >=14} + + rolldown@1.2.19: + resolution: {integrity: sha512-QIiV1J9d0pzN4jeeTH4sjPy0AZ6cAy2cG0ExeoE1+U8Rvj+hR3gYkokx0YbeUNGlZqiQJJ2utcETe0oKXwzsuA==} + engines: {node: ^20.19.0 || >=22.12.0} + hasBin: true + + source-map-js@1.2.4: + resolution: {integrity: sha512-J7ZjMvHd9O1fcT/5V09QWaaSl2BbWx3F6O08spde82Namf9UB0GxRVIPiNbVsdKkoizHiSpTodo3vp2bAy91MA==} + engines: {node: '>=6.0.0'} + + tinyglobby@0.2.17: + resolution: {integrity: sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==} + engines: {node: '>=12.0.0'} + + tslib@2.9.1: + resolution: {integrity: sha512-a4Ux9VKuIMHsOS7ENbEq6hK2ZGYIT27Rtl0E4eD9KqwxhKiQeMZE/9xb3IdYwWaSOyIBQLExhQgXDTYoiCxnWA==} + + typescript@7.0.2: + resolution: {integrity: sha512-8FYau96o3NKOhbjKi/qNvG/W5jhzxkbdm5sj9AbZ/5T5sWqn3hJgLfGx27sRKZWTvyzCP8dLRBTf5tBTSRVUNA==} + engines: {node: '>=16.20.0'} + hasBin: true + + vite@8.3.8: + resolution: {integrity: sha512-LzOn3h9rG/0vhLdXrV4yJ4QFA9eEoqCl+Yx+kGJd7aB9w6nfNgVHKSYwLPZUHrz4ZGa+t+kXjV9itvcHDLQouA==} + engines: {node: ^20.19.0 || >=22.12.0} + hasBin: true + peerDependencies: + '@types/node': ^20.19.0 || >=22.12.0 + '@vitejs/devtools': ^0.7.1 || ^0.8.0 + esbuild: ^0.27.0 || ^0.28.0 + jiti: '>=1.21.0' + less: ^4.0.0 + sass: ^1.70.0 + sass-embedded: ^1.70.0 + stylus: '>=0.54.8' + sugarss: ^5.0.0 + terser: ^5.16.0 + tsx: ^4.8.1 + yaml: ^2.4.2 + peerDependenciesMeta: + '@types/node': + optional: true + '@vitejs/devtools': + optional: true + esbuild: + optional: true + jiti: + optional: true + less: + optional: true + sass: + optional: true + sass-embedded: + optional: true + stylus: + optional: true + sugarss: + optional: true + terser: + optional: true + tsx: + optional: true + yaml: + optional: true + +snapshots: + + '@emnapi/core@2.0.0-beta.2': + dependencies: + '@emnapi/wasi-threads': 2.2.0 + tslib: 2.9.1 + optional: true + + '@emnapi/runtime@2.0.0-beta.2': + dependencies: + tslib: 2.9.1 + optional: true + + '@emnapi/wasi-threads@2.2.0': + dependencies: + tslib: 2.9.1 + optional: true + + '@napi-rs/wasm-runtime@1.2.6(@emnapi/core@2.0.0-beta.2)(@emnapi/runtime@2.0.0-beta.2)': + dependencies: + '@emnapi/core': 2.0.0-beta.2 + '@emnapi/runtime': 2.0.0-beta.2 + '@tybys/wasm-util': 0.10.5 + optional: true + + '@oxc-project/types@0.156.0': {} + + '@rolldown/binding-android-arm-eabi@1.2.19': + optional: true + + '@rolldown/binding-android-arm64@1.2.19': + optional: true + + '@rolldown/binding-darwin-arm64@1.2.19': + optional: true + + '@rolldown/binding-darwin-x64@1.2.19': + optional: true + + '@rolldown/binding-freebsd-x64@1.2.19': + optional: true + + '@rolldown/binding-linux-arm-gnueabihf@1.2.19': + optional: true + + '@rolldown/binding-linux-arm64-gnu@1.2.19': + optional: true + + '@rolldown/binding-linux-arm64-musl@1.2.19': + optional: true + + '@rolldown/binding-linux-ppc64-gnu@1.2.19': + optional: true + + '@rolldown/binding-linux-s390x-gnu@1.2.19': + optional: true + + '@rolldown/binding-linux-x64-gnu@1.2.19': + optional: true + + '@rolldown/binding-linux-x64-musl@1.2.19': + optional: true + + '@rolldown/binding-openharmony-arm64@1.2.19': + optional: true + + '@rolldown/binding-wasm32-wasi@1.2.19': + dependencies: + '@emnapi/core': 2.0.0-beta.2 + '@emnapi/runtime': 2.0.0-beta.2 + '@napi-rs/wasm-runtime': 1.2.6(@emnapi/core@2.0.0-beta.2)(@emnapi/runtime@2.0.0-beta.2) + optional: true + + '@rolldown/binding-win32-arm64-msvc@1.2.19': + optional: true + + '@rolldown/binding-win32-x64-msvc@1.2.19': + optional: true + + '@rolldown/pluginutils@1.1.1': {} + + '@tybys/wasm-util@0.10.5': + dependencies: + tslib: 2.9.1 + optional: true + + '@typescript/typescript-aix-ppc64@7.0.2': + optional: true + + '@typescript/typescript-darwin-arm64@7.0.2': + optional: true + + '@typescript/typescript-darwin-x64@7.0.2': + optional: true + + '@typescript/typescript-freebsd-arm64@7.0.2': + optional: true + + '@typescript/typescript-freebsd-x64@7.0.2': + optional: true + + '@typescript/typescript-linux-arm64@7.0.2': + optional: true + + '@typescript/typescript-linux-arm@7.0.2': + optional: true + + '@typescript/typescript-linux-loong64@7.0.2': + optional: true + + '@typescript/typescript-linux-mips64el@7.0.2': + optional: true + + '@typescript/typescript-linux-ppc64@7.0.2': + optional: true + + '@typescript/typescript-linux-riscv64@7.0.2': + optional: true + + '@typescript/typescript-linux-s390x@7.0.2': + optional: true + + '@typescript/typescript-linux-x64@7.0.2': + optional: true + + '@typescript/typescript-netbsd-arm64@7.0.2': + optional: true + + '@typescript/typescript-netbsd-x64@7.0.2': + optional: true + + '@typescript/typescript-openbsd-arm64@7.0.2': + optional: true + + '@typescript/typescript-openbsd-x64@7.0.2': + optional: true + + '@typescript/typescript-sunos-x64@7.0.2': + optional: true + + '@typescript/typescript-win32-arm64@7.0.2': + optional: true + + '@typescript/typescript-win32-x64@7.0.2': + optional: true + + detect-libc@2.1.2: {} + + fdir@6.5.0(picomatch@4.0.7): + optionalDependencies: + picomatch: 4.0.7 + + fsevents@2.3.3: + optional: true + + lightningcss-android-arm64@1.33.0: + optional: true + + lightningcss-darwin-arm64@1.33.0: + optional: true + + lightningcss-darwin-x64@1.33.0: + optional: true + + lightningcss-freebsd-x64@1.33.0: + optional: true + + lightningcss-linux-arm-gnueabihf@1.33.0: + optional: true + + lightningcss-linux-arm64-gnu@1.33.0: + optional: true + + lightningcss-linux-arm64-musl@1.33.0: + optional: true + + lightningcss-linux-x64-gnu@1.33.0: + optional: true + + lightningcss-linux-x64-musl@1.33.0: + optional: true + + lightningcss-win32-arm64-msvc@1.33.0: + optional: true + + lightningcss-win32-x64-msvc@1.33.0: + optional: true + + lightningcss@1.33.0: + dependencies: + detect-libc: 2.1.2 + optionalDependencies: + lightningcss-android-arm64: 1.33.0 + lightningcss-darwin-arm64: 1.33.0 + lightningcss-darwin-x64: 1.33.0 + lightningcss-freebsd-x64: 1.33.0 + lightningcss-linux-arm-gnueabihf: 1.33.0 + lightningcss-linux-arm64-gnu: 1.33.0 + lightningcss-linux-arm64-musl: 1.33.0 + lightningcss-linux-x64-gnu: 1.33.0 + lightningcss-linux-x64-musl: 1.33.0 + lightningcss-win32-arm64-msvc: 1.33.0 + lightningcss-win32-x64-msvc: 1.33.0 + + nanoid@3.3.20: {} + + picocolors@1.1.1: {} + + picomatch@4.0.7: {} + + postcss@8.5.33: + dependencies: + nanoid: 3.3.20 + picocolors: 1.1.1 + source-map-js: 1.2.4 + + rolldown@1.2.19: + dependencies: + '@oxc-project/types': 0.156.0 + '@rolldown/pluginutils': 1.1.1 + optionalDependencies: + '@rolldown/binding-android-arm-eabi': 1.2.19 + '@rolldown/binding-android-arm64': 1.2.19 + '@rolldown/binding-darwin-arm64': 1.2.19 + '@rolldown/binding-darwin-x64': 1.2.19 + '@rolldown/binding-freebsd-x64': 1.2.19 + '@rolldown/binding-linux-arm-gnueabihf': 1.2.19 + '@rolldown/binding-linux-arm64-gnu': 1.2.19 + '@rolldown/binding-linux-arm64-musl': 1.2.19 + '@rolldown/binding-linux-ppc64-gnu': 1.2.19 + '@rolldown/binding-linux-s390x-gnu': 1.2.19 + '@rolldown/binding-linux-x64-gnu': 1.2.19 + '@rolldown/binding-linux-x64-musl': 1.2.19 + '@rolldown/binding-openharmony-arm64': 1.2.19 + '@rolldown/binding-wasm32-wasi': 1.2.19 + '@rolldown/binding-win32-arm64-msvc': 1.2.19 + '@rolldown/binding-win32-x64-msvc': 1.2.19 + + source-map-js@1.2.4: {} + + tinyglobby@0.2.17: + dependencies: + fdir: 6.5.0(picomatch@4.0.7) + picomatch: 4.0.7 + + tslib@2.9.1: + optional: true + + typescript@7.0.2: + optionalDependencies: + '@typescript/typescript-aix-ppc64': 7.0.2 + '@typescript/typescript-darwin-arm64': 7.0.2 + '@typescript/typescript-darwin-x64': 7.0.2 + '@typescript/typescript-freebsd-arm64': 7.0.2 + '@typescript/typescript-freebsd-x64': 7.0.2 + '@typescript/typescript-linux-arm': 7.0.2 + '@typescript/typescript-linux-arm64': 7.0.2 + '@typescript/typescript-linux-loong64': 7.0.2 + '@typescript/typescript-linux-mips64el': 7.0.2 + '@typescript/typescript-linux-ppc64': 7.0.2 + '@typescript/typescript-linux-riscv64': 7.0.2 + '@typescript/typescript-linux-s390x': 7.0.2 + '@typescript/typescript-linux-x64': 7.0.2 + '@typescript/typescript-netbsd-arm64': 7.0.2 + '@typescript/typescript-netbsd-x64': 7.0.2 + '@typescript/typescript-openbsd-arm64': 7.0.2 + '@typescript/typescript-openbsd-x64': 7.0.2 + '@typescript/typescript-sunos-x64': 7.0.2 + '@typescript/typescript-win32-arm64': 7.0.2 + '@typescript/typescript-win32-x64': 7.0.2 + + vite@8.3.8: + dependencies: + lightningcss: 1.33.0 + picomatch: 4.0.7 + postcss: 8.5.33 + rolldown: 1.2.19 + tinyglobby: 0.2.17 + optionalDependencies: + fsevents: 2.3.3 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml new file mode 100644 index 0000000..6d40426 --- /dev/null +++ b/pnpm-workspace.yaml @@ -0,0 +1,5 @@ +# Only install package versions published at least 7 days ago (in minutes). +minimumReleaseAge: 10080 + +allowBuilds: + esbuild: true diff --git a/public/favicon.svg b/public/favicon.svg new file mode 100644 index 0000000..8a28fd8 --- /dev/null +++ b/public/favicon.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/public/preview.png b/public/preview.png new file mode 100644 index 0000000..0430146 Binary files /dev/null and b/public/preview.png differ diff --git a/scripts/smoke5.py b/scripts/smoke5.py new file mode 100644 index 0000000..f3b631d --- /dev/null +++ b/scripts/smoke5.py @@ -0,0 +1,127 @@ +# Smoke-test the built Day 5 pelican-on-a-bike game: start, jump, duck, crash, best-score persistence, reindeer, preview shot. +import http.server, threading, functools, sys, os +DIST = os.path.abspath(sys.argv[1] if len(sys.argv) > 1 else 'dist') +SHOT = os.environ.get('SHOT', '') # if set, capture 1200x630 preview here +httpd = http.server.ThreadingHTTPServer(('127.0.0.1', 8767), functools.partial(http.server.SimpleHTTPRequestHandler, directory=DIST)) +threading.Thread(target=httpd.serve_forever, daemon=True).start() +from playwright.sync_api import sync_playwright +errs, msgs = [], [] +with sync_playwright() as p: + b = p.chromium.launch( + executable_path='/home/hermeswebui/.hermes/home/.cache/ms-playwright/chromium-1234/chrome-linux64/chrome', + args=['--no-sandbox', '--disable-gpu', '--disable-dev-shm-usage']) + pg = b.new_page(viewport={'width': 1200, 'height': 630}) + pg.on('pageerror', lambda e: errs.append(str(e))) + pg.on('console', lambda m: msgs.append(f"{m.type}: {m.text}")) + pg.goto('http://127.0.0.1:8767/', wait_until='networkidle') + pg.wait_for_timeout(500) + print('title:', pg.title()) + assert 'Day 5' in pg.title() + assert pg.locator('#menu').is_visible(), 'menu should show on load' + + # start as pelican + pg.click('#card-pelican') + assert pg.evaluate('window.__aos5.phase') == 'playing' + # park the obstacle spawner far away so the physics checks run on a clean road + pg.evaluate('window.__aos5.distSinceSpawn = -1e9') + pg.wait_for_timeout(2500) + score = int(pg.locator('#hud-score').inner_text()) + dist = int(pg.locator('#hud-dist').inner_text()) + kmh = int(pg.locator('#hud-speed').inner_text()) + print(f'after 2.5s: score={score} dist={dist}m kmh={kmh}') + assert score > 0 and dist > 0 and kmh > 0 + + # jump raises the rider + y0 = pg.evaluate('window.__aos5.rider.y') + pg.keyboard.press('Space') + pg.wait_for_timeout(250) + y1 = pg.evaluate('window.__aos5.rider.y') + print('jump: y', y0, '->', y1) + assert y1 < y0, 'rider did not leave the ground' + pg.wait_for_timeout(900) + assert pg.evaluate('window.__aos5.rider.onGround') is True, 'rider never landed' + + # duck lowers the hitbox + pg.keyboard.down('ArrowDown') + pg.wait_for_timeout(400) + duck = pg.evaluate('window.__aos5.duckOn') + assert duck is True + pg.keyboard.up('ArrowDown') + + # pause / resume + pg.keyboard.press('KeyP') + assert pg.evaluate('window.__aos5.phase') == 'paused' + assert pg.locator('#pause').is_visible() + pg.keyboard.press('KeyP') + assert pg.evaluate('window.__aos5.phase') == 'playing' + + if SHOT: + pg.evaluate('window.__aos5.distSinceSpawn = 0') # let traffic come back for the screenshot + # wait until an obstacle is nicely on screen, then style the page to fit 1200x630 + for _ in range(60): + near = pg.evaluate("window.__aos5.obstacles.filter(o => o.kind !== 'garland' && o.x > 380 && o.x < 1000).length") + if near >= 1: + break + pg.keyboard.press('Space') + pg.wait_for_timeout(400) + pg.evaluate('''() => { + document.querySelector('header').style.display = 'none'; + document.querySelector('.hint').style.display = 'none'; + const app = document.getElementById('app'); + app.style.padding = '0'; app.style.maxWidth = '1200px'; + const hud = document.getElementById('hud'); + hud.style.margin = '0'; hud.style.height = '30px'; hud.style.alignItems = 'center'; + hud.style.overflow = 'hidden'; + const stage = document.getElementById('stage'); + stage.style.border = 'none'; stage.style.borderRadius = '0'; + const cv = document.getElementById('game'); + cv.style.width = '1200px'; cv.style.height = '600px'; + document.body.style.overflow = 'hidden'; + window.scrollTo(0, 0); + }''') + pg.wait_for_timeout(300) + box = pg.locator('#game').bounding_box() + print('canvas box for shot:', box) + assert box['y'] >= 28 and box['y'] + box['height'] <= 632, 'canvas not framed in 630px' + pg.screenshot(path=SHOT, clip={'x': 0, 'y': 0, 'width': 1200, 'height': 630}) + print('preview shot ->', SHOT) + pg.reload(wait_until='networkidle') + pg.wait_for_timeout(400) + + # force a crash -> overlay + best score + if pg.evaluate('window.__aos5.phase') != 'playing': + pg.click('#card-pelican') + pg.wait_for_timeout(1200) + pg.evaluate('window.__aos5.crash()') + pg.wait_for_timeout(1500) + assert pg.locator('#gameover').is_visible(), 'game over overlay missing' + fs = int(pg.locator('#final-score').inner_text()) + print('crash final score:', fs) + assert fs > 0 + best_txt = pg.locator('#best-line').inner_text() + print('best line:', best_txt) + + # restart via button, ride as reindeer, double jump + pg.click('#restart-btn') + pg.evaluate("window.__aos5.setChar('reindeer', 0); window.__aos5.start()") + pg.keyboard.press('Space') + pg.wait_for_timeout(120) + pg.keyboard.press('Space') # double jump + jl = pg.evaluate('window.__aos5.rider.jumpsLeft') + print('reindeer jumps left after double jump:', jl) + assert jl == 0 + pg.wait_for_timeout(600) + + # best persists across reload + pg.reload(wait_until='networkidle') + pg.wait_for_timeout(400) + stored = pg.evaluate("localStorage.getItem('aos5-best-pelican')") + print('persisted pelican best:', stored) + assert stored is not None and int(stored) > 0 + + print('pageerrors:', errs) + assert not errs, f'JS page errors: {errs}' + bad = [m for m in msgs if m.startswith('error')] + assert not bad, f'console errors: {bad}' + print('SMOKE OK') + b.close() diff --git a/src/art.ts b/src/art.ts new file mode 100644 index 0000000..f4cc901 --- /dev/null +++ b/src/art.ts @@ -0,0 +1,584 @@ +// All canvas drawing for Day 5: winter city, obstacles, pickups, and the two riders. +// Everything is drawn with paths — no images, no fonts beyond numbers. + +export const W = 1200; +export const H = 600; +export const GROUND = 508; // wheel-contact line + +export interface Building { + x: number; w: number; h: number; + tone: number; // 0..1 darkness + seed: number; // window layout seed + spire: boolean; +} + +export interface Obstacle { + kind: 'pothole' | 'snowman' | 'tree' | 'gift' | 'bin' | 'garland'; + x: number; w: number; h: number; // h = height above ground (garland: box top offset) + seed: number; +} + +export interface Pickup { kind: 'fish' | 'carrot'; x: number; y: number; taken: boolean } + +export interface Flake { x: number; y: number; r: number; vy: number; sway: number; phase: number } + +// deterministic little PRNG so a building's windows never flicker between frames +const rand = (n: number): number => { + const x = Math.sin(n * 127.1 + 311.7) * 43758.5453; + return x - Math.floor(x); +}; + +export function makeBuilding(x: number, layer: number): Building { + const s = Math.random() * 10000; + const hRange = layer === 0 ? [140, 300] : layer === 1 ? [100, 220] : [70, 150]; + const h = hRange[0]! + Math.random() * (hRange[1]! - hRange[0]!); + const w = layer === 0 ? 70 + Math.random() * 90 : layer === 1 ? 60 + Math.random() * 80 : 55 + Math.random() * 70; + return { x, w, h, tone: Math.random(), seed: s, spire: Math.random() < 0.16 }; +} + +export function drawSky(ctx: CRenderingContext, t: number): void { + const g = ctx.createLinearGradient(0, 0, 0, GROUND); + g.addColorStop(0, '#0c1024'); + g.addColorStop(0.55, '#1c2748'); + g.addColorStop(0.85, '#3a3f6b'); + g.addColorStop(1, '#6b4a63'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, W, GROUND); + + // stars + for (let i = 0; i < 70; i++) { + const x = rand(i * 3.7) * W; + const y = rand(i * 9.1) * GROUND * 0.55; + const tw = 0.35 + 0.65 * Math.abs(Math.sin(t * (0.6 + rand(i) * 1.4) + i)); + ctx.fillStyle = `rgba(240,240,255,${(0.25 + 0.5 * tw) * (1 - y / (GROUND * 0.7))})`; + ctx.fillRect(x, y, 2, 2); + } + + // moon with halo + const mx = 1010, my = 92; + const halo = ctx.createRadialGradient(mx, my, 8, mx, my, 60); + halo.addColorStop(0, 'rgba(255,244,214,0.55)'); + halo.addColorStop(1, 'rgba(255,244,214,0)'); + ctx.fillStyle = halo; + ctx.fillRect(mx - 60, my - 60, 120, 120); + ctx.fillStyle = '#f8ecc8'; + ctx.beginPath(); ctx.arc(mx, my, 26, 0, Math.PI * 2); ctx.fill(); + ctx.fillStyle = 'rgba(200,180,140,0.35)'; + ctx.beginPath(); ctx.arc(mx - 8, my - 6, 5, 0, Math.PI * 2); ctx.fill(); + ctx.beginPath(); ctx.arc(mx + 7, my + 8, 7, 0, Math.PI * 2); ctx.fill(); +} + +export function drawBuildings(ctx: CRenderingContext, list: Building[], layer: number, t: number): void { + const baseY = GROUND - (layer === 2 ? 26 : layer === 1 ? 12 : 0); + const dark = layer === 0 ? ['#141a33', '#182040'] : layer === 1 ? ['#1d2547', '#232c52'] : ['#2a3358', '#323d66']; + for (const b of list) { + if (b.x > W + 10 || b.x + b.w < -10) continue; + const top = baseY - b.h; + ctx.fillStyle = dark[b.tone > 0.5 ? 1 : 0]!; + ctx.fillRect(b.x, top, b.w, b.h); + if (b.spire) { // little church spire on some rooftops + ctx.beginPath(); + ctx.moveTo(b.x + b.w * 0.5 - 8, top); + ctx.lineTo(b.x + b.w * 0.5, top - 34); + ctx.lineTo(b.x + b.w * 0.5 + 8, top); + ctx.closePath(); + ctx.fill(); + } + // roof snow + ctx.fillStyle = 'rgba(226,234,250,0.85)'; + ctx.fillRect(b.x - 2, top, b.w + 4, 5); + // windows + if (layer > 0) { + const cols = Math.max(2, Math.floor(b.w / 22)); + const rows = Math.max(2, Math.floor(b.h / 26)); + for (let r = 0; r < rows; r++) { + for (let c = 0; c < cols; c++) { + const v = rand(b.seed + r * 31.3 + c * 7.7); + if (v < 0.42) continue; + const flick = v > 0.9 ? 0.6 + 0.4 * Math.sin(t * 3 + b.seed + r) : 1; + const warm = v > 0.75; + ctx.fillStyle = warm + ? `rgba(255,196,102,${0.75 * flick})` + : `rgba(160,200,255,${0.4 * flick})`; + ctx.fillRect(b.x + 8 + c * ((b.w - 16) / cols), top + 12 + r * ((b.h - 20) / rows), 8, 10); + } + } + } + } +} + +export function drawStreet(ctx: CRenderingContext, scroll: number): void { + // sidewalk + ctx.fillStyle = '#cfd8ea'; + ctx.fillRect(0, GROUND - 26, W, 26); + ctx.fillStyle = '#eef3fb'; + ctx.fillRect(0, GROUND - 26, W, 6); + // curb shadow + ctx.fillStyle = '#9aa6c0'; + ctx.fillRect(0, GROUND - 4, W, 4); + // road + const road = ctx.createLinearGradient(0, GROUND, 0, H); + road.addColorStop(0, '#3a4056'); + road.addColorStop(1, '#232838'); + ctx.fillStyle = road; + ctx.fillRect(0, GROUND, W, H - GROUND); + // slushy lane dashes + ctx.fillStyle = 'rgba(226,234,250,0.5)'; + const dash = 46, gap = 58; + const off = scroll % (dash + gap); + for (let x = -off; x < W; x += dash + gap) { + ctx.fillRect(x, GROUND + 44, dash, 6); + } + // snowbanks on the sidewalk, scrolling with the near layer + ctx.fillStyle = '#e8eefb'; + const bank = 210; + const boff = scroll % bank; + for (let x = -boff; x < W + bank; x += bank) { + const s = rand(Math.floor((scroll + x) / bank) * 13.7); + ctx.beginPath(); + ctx.ellipse(x, GROUND - 6, 40 + s * 30, 9 + s * 5, 0, Math.PI, 0); + ctx.fill(); + } +} + +export function drawLamp(ctx: CRenderingContext, x: number, t: number): void { + ctx.strokeStyle = '#4a5474'; + ctx.lineWidth = 5; + ctx.beginPath(); + ctx.moveTo(x, GROUND - 6); + ctx.lineTo(x, GROUND - 150); + ctx.quadraticCurveTo(x, GROUND - 168, x + 22, GROUND - 168); + ctx.stroke(); + ctx.lineWidth = 1; + // lamp head + glow + const gx = x + 26, gy = GROUND - 164; + const glow = ctx.createRadialGradient(gx, gy, 2, gx, gy, 46); + glow.addColorStop(0, `rgba(255,214,140,${0.5 + 0.06 * Math.sin(t * 7 + x)})`); + glow.addColorStop(1, 'rgba(255,214,140,0)'); + ctx.fillStyle = glow; + ctx.fillRect(gx - 46, gy - 46, 92, 92); + ctx.fillStyle = '#ffdf9e'; + ctx.beginPath(); ctx.ellipse(gx, gy, 8, 6, 0, 0, Math.PI * 2); ctx.fill(); + ctx.fillStyle = '#38405c'; + ctx.fillRect(gx - 10, gy - 12, 20, 6); +} + +export function drawGarland(ctx: CRenderingContext, o: Obstacle, t: number): void { + const topY = GROUND - 150; + const sag = GROUND - 66; + const x1 = o.x, x2 = o.x + o.w; + // poles + ctx.strokeStyle = '#4a5474'; + ctx.lineWidth = 5; + ctx.beginPath(); ctx.moveTo(x1, GROUND - 6); ctx.lineTo(x1, topY); ctx.stroke(); + ctx.beginPath(); ctx.moveTo(x2, GROUND - 6); ctx.lineTo(x2, topY); ctx.stroke(); + ctx.lineWidth = 1; + // string + ctx.strokeStyle = '#69719a'; + ctx.beginPath(); + ctx.moveTo(x1, topY); + ctx.quadraticCurveTo((x1 + x2) / 2, sag + 26, x2, topY); + ctx.stroke(); + // bulbs along the quadratic + const colors = ['#ff5d5d', '#ffd166', '#5dd06a', '#5da9ff']; + const n = 11; + for (let i = 1; i < n; i++) { + const u = i / n; + const bx = (1 - u) * (1 - u) * x1 + 2 * (1 - u) * u * ((x1 + x2) / 2) + u * u * x2; + const by = (1 - u) * (1 - u) * topY + 2 * (1 - u) * u * (sag + 26) + u * u * topY; + const c = colors[i % colors.length]!; + const pulse = 0.65 + 0.35 * Math.sin(t * 4 + i * 1.3); + const g = ctx.createRadialGradient(bx, by + 8, 1, bx, by + 8, 14); + g.addColorStop(0, c + 'aa'); + g.addColorStop(1, c + '00'); + ctx.fillStyle = g; + ctx.fillRect(bx - 14, by - 6, 28, 28); + ctx.globalAlpha = 0.55 + 0.45 * pulse; + ctx.fillStyle = c; + ctx.beginPath(); ctx.ellipse(bx, by + 8, 4.5, 6.5, 0, 0, Math.PI * 2); ctx.fill(); + ctx.globalAlpha = 1; + } +} + +export function drawObstacle(ctx: CRenderingContext, o: Obstacle, t: number): void { + const g = GROUND; + switch (o.kind) { + case 'pothole': { + ctx.fillStyle = '#161a26'; + ctx.beginPath(); + ctx.ellipse(o.x + o.w / 2, g + 16, o.w / 2, 10, 0, 0, Math.PI * 2); + ctx.fill(); + ctx.strokeStyle = 'rgba(226,234,250,0.5)'; + ctx.beginPath(); + ctx.ellipse(o.x + o.w / 2, g + 14, o.w / 2 + 4, 12, 0, Math.PI * 1.05, Math.PI * 1.95); + ctx.stroke(); + break; + } + case 'snowman': { + const cx = o.x + o.w / 2; + ctx.fillStyle = '#f2f6ff'; + ctx.beginPath(); ctx.arc(cx, g - 20, 20, 0, Math.PI * 2); ctx.fill(); + ctx.beginPath(); ctx.arc(cx, g - 50, 14, 0, Math.PI * 2); ctx.fill(); + ctx.beginPath(); ctx.arc(cx, g - 72, 10, 0, Math.PI * 2); ctx.fill(); + ctx.fillStyle = '#20242f'; + ctx.beginPath(); ctx.arc(cx - 4, g - 74, 1.8, 0, Math.PI * 2); ctx.fill(); + ctx.beginPath(); ctx.arc(cx + 3, g - 74, 1.8, 0, Math.PI * 2); ctx.fill(); + ctx.fillStyle = '#ff7f3f'; // carrot nose + ctx.beginPath(); ctx.moveTo(cx + 8, g - 72); ctx.lineTo(cx + 20, g - 69); ctx.lineTo(cx + 8, g - 67); ctx.fill(); + ctx.fillStyle = '#b8232f'; // hat + ctx.fillRect(cx - 12, g - 84, 24, 4); + ctx.fillRect(cx - 8, g - 96, 16, 13); + ctx.strokeStyle = '#7a5a3a'; // twig arms + ctx.lineWidth = 2; + ctx.beginPath(); ctx.moveTo(cx - 12, g - 52); ctx.lineTo(cx - 26, g - 62); ctx.stroke(); + ctx.beginPath(); ctx.moveTo(cx + 12, g - 52); ctx.lineTo(cx + 26, g - 60); ctx.stroke(); + ctx.lineWidth = 1; + break; + } + case 'tree': { + const cx = o.x + o.w / 2; + ctx.fillStyle = '#5a3a26'; + ctx.fillRect(cx - 5, g - 18, 10, 18); + const green = ['#1e5c3a', '#236b44', '#2a7a4e']; + for (let i = 0; i < 3; i++) { + const y = g - 18 - i * 24; + const wHalf = 30 - i * 7; + ctx.fillStyle = green[i]!; + ctx.beginPath(); + ctx.moveTo(cx - wHalf, y); + ctx.lineTo(cx, y - 34); + ctx.lineTo(cx + wHalf, y); + ctx.closePath(); + ctx.fill(); + ctx.fillStyle = 'rgba(232,238,251,0.8)'; + ctx.beginPath(); + ctx.moveTo(cx - wHalf, y); + ctx.lineTo(cx, y - 34); + ctx.lineTo(cx + wHalf, y); + ctx.lineTo(cx + wHalf - 8, y); + ctx.lineTo(cx, y - 26); + ctx.lineTo(cx - wHalf + 8, y); + ctx.closePath(); + ctx.fill(); + } + // star + ctx.fillStyle = '#ffd166'; + ctx.beginPath(); + ctx.arc(cx, g - 92, 4, 0, Math.PI * 2); + ctx.fill(); + break; + } + case 'gift': { + const boxes = [ + { dx: 0, w: 46, h: 30, c: '#b8232f', r: '#ffd166' }, + { dx: 8, w: 34, h: 24, c: '#2f7d5c', r: '#f2ecdd' }, + ]; + let y = g; + for (const bx of boxes) { + y -= bx.h; + ctx.fillStyle = bx.c; + ctx.fillRect(o.x + bx.dx, y, bx.w, bx.h); + ctx.fillStyle = bx.r; + ctx.fillRect(o.x + bx.dx + bx.w / 2 - 3, y, 6, bx.h); + ctx.fillRect(o.x + bx.dx, y + bx.h / 2 - 2, bx.w, 4); + } + ctx.strokeStyle = 'rgba(232,238,251,0.7)'; + ctx.strokeRect(o.x - 1, g - 55, 48, 1); + break; + } + case 'bin': { + ctx.fillStyle = '#2f5d4a'; + ctx.beginPath(); + ctx.moveTo(o.x + 4, g); + ctx.lineTo(o.x, g - 52); + ctx.lineTo(o.x + 40, g - 52); + ctx.lineTo(o.x + 36, g); + ctx.closePath(); + ctx.fill(); + ctx.fillStyle = '#3d7460'; + ctx.fillRect(o.x - 3, g - 60, 46, 9); + ctx.fillStyle = '#20453a'; + ctx.fillRect(o.x + 14, g - 66, 12, 6); + // overflowing snow bag + ctx.fillStyle = '#dfe6f4'; + ctx.beginPath(); ctx.arc(o.x + 20, g - 66, 10, Math.PI, 0); ctx.fill(); + break; + } + case 'garland': + drawGarland(ctx, o, t); + break; + } +} + +export function drawPickup(ctx: CRenderingContext, p: Pickup, t: number): void { + if (p.taken) return; + const bob = Math.sin(t * 3 + p.x * 0.05) * 5; + const y = p.y + bob; + ctx.save(); + ctx.translate(p.x, y); + const glow = ctx.createRadialGradient(0, 0, 2, 0, 0, 26); + glow.addColorStop(0, 'rgba(255,220,150,0.35)'); + glow.addColorStop(1, 'rgba(255,220,150,0)'); + ctx.fillStyle = glow; + ctx.fillRect(-26, -26, 52, 52); + if (p.kind === 'fish') { + ctx.rotate(Math.sin(t * 2 + p.x) * 0.12); + ctx.fillStyle = '#b8c8dd'; + ctx.beginPath(); ctx.ellipse(0, 0, 15, 8, 0, 0, Math.PI * 2); ctx.fill(); + ctx.fillStyle = '#93a7c2'; + ctx.beginPath(); ctx.moveTo(-13, 0); ctx.lineTo(-22, -7); ctx.lineTo(-22, 7); ctx.closePath(); ctx.fill(); + ctx.fillStyle = '#20242f'; + ctx.beginPath(); ctx.arc(7, -2, 1.8, 0, Math.PI * 2); ctx.fill(); + ctx.strokeStyle = 'rgba(255,255,255,0.5)'; + ctx.beginPath(); ctx.arc(2, 0, 8, -0.6, 0.9); ctx.stroke(); + } else { + ctx.fillStyle = '#ff8c42'; + ctx.beginPath(); ctx.moveTo(12, -4); ctx.lineTo(-10, 6); ctx.lineTo(-8, 12); ctx.lineTo(12, 2); ctx.closePath(); ctx.fill(); + ctx.fillStyle = '#3f9d5a'; + ctx.beginPath(); + ctx.moveTo(11, -3); ctx.quadraticCurveTo(18, -14, 22, -10); + ctx.quadraticCurveTo(17, -6, 13, 0); ctx.closePath(); ctx.fill(); + ctx.beginPath(); + ctx.moveTo(12, 0); ctx.quadraticCurveTo(23, -6, 25, -1); + ctx.quadraticCurveTo(18, 1, 13, 3); ctx.closePath(); ctx.fill(); + } + ctx.restore(); +} + +// ---------- riders ---------- + +function wheel(ctx: CRenderingContext, cx: number, cy: number, r: number, spin: number): void { + ctx.strokeStyle = '#181c28'; + ctx.lineWidth = 5; + ctx.beginPath(); ctx.arc(cx, cy, r, 0, Math.PI * 2); ctx.stroke(); + ctx.strokeStyle = '#8f9ab8'; + ctx.lineWidth = 1.6; + for (let i = 0; i < 3; i++) { + const a = spin + (i * Math.PI) / 3; + ctx.beginPath(); + ctx.moveTo(cx - Math.cos(a) * r, cy - Math.sin(a) * r); + ctx.lineTo(cx + Math.cos(a) * r, cy + Math.sin(a) * r); + ctx.stroke(); + } + ctx.fillStyle = '#c9d2e6'; + ctx.beginPath(); ctx.arc(cx, cy, 3, 0, Math.PI * 2); ctx.fill(); + ctx.lineWidth = 1; +} + +function leg(ctx: CRenderingContext, hipX: number, hipY: number, footX: number, footY: number): void { + const kneeX = (hipX + footX) / 2 + 12; + const kneeY = (hipY + footY) / 2 + 6; + ctx.strokeStyle = '#d9a24a'; + ctx.lineWidth = 5; + ctx.beginPath(); + ctx.moveTo(hipX, hipY); + ctx.quadraticCurveTo(kneeX, kneeY, footX, footY); + ctx.stroke(); + ctx.lineWidth = 1; +} + +export function drawPelican(ctx: CRenderingContext, x: number, y: number, crank: number, duck: number, t: number): void { + // bicycle + const wr = 24; + const rear = { x: x - 36, y: y - wr }; + const front = { x: x + 36, y: y - wr }; + wheel(ctx, rear.x, rear.y, wr, crank); + wheel(ctx, front.x, front.y, wr, crank); + ctx.strokeStyle = '#c23a3a'; + ctx.lineWidth = 4; + ctx.beginPath(); + ctx.moveTo(rear.x, rear.y); ctx.lineTo(x - 4, y - 52); ctx.lineTo(front.x, front.y); // rear triangle to seat tube + ctx.moveTo(x - 4, y - 52); ctx.lineTo(x + 2, y - 26); ctx.lineTo(rear.x, rear.y); // seat stays + ctx.moveTo(x + 2, y - 26); ctx.lineTo(front.x - 6, y - 56); // down tube + ctx.moveTo(front.x - 6, y - 56); ctx.lineTo(front.x, front.y); // fork + ctx.stroke(); + ctx.lineWidth = 1; + // handlebar + ctx.strokeStyle = '#39415f'; + ctx.lineWidth = 3.5; + ctx.beginPath(); + ctx.moveTo(front.x - 6, y - 56); ctx.lineTo(front.x + 2, y - 66); ctx.lineTo(front.x + 12, y - 62); + ctx.stroke(); + ctx.lineWidth = 1; + // pedals + const px = x + 2 + Math.cos(crank * 2) * 13; + const py = y - 26 + Math.sin(crank * 2) * 13; + const px2 = x + 2 - Math.cos(crank * 2) * 13; + const py2 = y - 26 - Math.sin(crank * 2) * 13; + ctx.strokeStyle = '#20242f'; + ctx.lineWidth = 3; + ctx.beginPath(); ctx.moveTo(px - 6, py); ctx.lineTo(px + 6, py); ctx.stroke(); + ctx.beginPath(); ctx.moveTo(px2 - 6, py2); ctx.lineTo(px2 + 6, py2); ctx.stroke(); + ctx.lineWidth = 1; + + const dip = duck * 20; // 0..1 duck amount + const bodyY = y - 78 + dip; + const bob = Math.sin(t * 11) * 1.4; + + // legs pedaling (behind body) + leg(ctx, x - 6, bodyY + 16, px, py); + leg(ctx, x - 8, bodyY + 16, px2, py2); + + // tail + ctx.fillStyle = '#e4ddca'; + ctx.beginPath(); + ctx.moveTo(x - 26, bodyY - 4 + bob); + ctx.lineTo(x - 44, bodyY - 12 + bob); + ctx.lineTo(x - 28, bodyY + 8 + bob); + ctx.closePath(); ctx.fill(); + + // body + ctx.fillStyle = '#f4f1e8'; + ctx.beginPath(); + ctx.ellipse(x - 4, bodyY + bob, 27, 20, -0.08, 0, Math.PI * 2); + ctx.fill(); + ctx.fillStyle = 'rgba(180,175,155,0.35)'; + ctx.beginPath(); + ctx.ellipse(x - 6, bodyY + 8 + bob, 22, 11, -0.08, 0, Math.PI); + ctx.fill(); + + // neck + head (tucked when ducking) + const headX = x + 26 - duck * 10; + const headY = bodyY - 30 + dip * 1.4 + bob; + ctx.strokeStyle = '#f4f1e8'; + ctx.lineWidth = 12; + ctx.lineCap = 'round'; + ctx.beginPath(); + ctx.moveTo(x + 8, bodyY - 6 + bob); + ctx.quadraticCurveTo(x + 22 - duck * 14, bodyY - 22 + dip + bob, headX, headY); + ctx.stroke(); + ctx.lineWidth = 1; + ctx.lineCap = 'butt'; + ctx.fillStyle = '#f4f1e8'; + ctx.beginPath(); ctx.arc(headX, headY, 11, 0, Math.PI * 2); ctx.fill(); + // crest tuft + ctx.strokeStyle = '#e4ddca'; + ctx.lineWidth = 2.5; + ctx.beginPath(); + ctx.moveTo(headX - 4, headY - 9); + ctx.quadraticCurveTo(headX - 10, headY - 18, headX - 4, headY - 20); + ctx.stroke(); + ctx.lineWidth = 1; + // beak with pouch + ctx.fillStyle = '#ff9d3c'; + ctx.beginPath(); + ctx.moveTo(headX + 6, headY - 5); + ctx.lineTo(headX + 46, headY + 1); + ctx.lineTo(headX + 8, headY + 6); + ctx.closePath(); ctx.fill(); + ctx.fillStyle = '#f2852a'; + ctx.beginPath(); + ctx.moveTo(headX + 8, headY + 4); + ctx.quadraticCurveTo(headX + 28, headY + 18, headX + 44, headY + 2); + ctx.lineTo(headX + 8, headY + 7); + ctx.closePath(); ctx.fill(); + // eye + ctx.fillStyle = '#20242f'; + ctx.beginPath(); ctx.arc(headX + 4, headY - 3, 2.2, 0, Math.PI * 2); ctx.fill(); + // wing reaching to the bar + ctx.fillStyle = '#e8e2d0'; + ctx.beginPath(); + ctx.moveTo(x + 2, bodyY - 6 + bob); + ctx.quadraticCurveTo(x + 24, bodyY - 2 + bob, front.x + 8, y - 64); + ctx.quadraticCurveTo(x + 20, bodyY + 6 + bob, x + 4, bodyY + 2 + bob); + ctx.closePath(); ctx.fill(); +} + +export function drawReindeer(ctx: CRenderingContext, x: number, y: number, crank: number, duck: number, t: number): void { + // unicycle + const wr = 27; + const hub = { x, y: y - wr }; + wheel(ctx, hub.x, hub.y, wr, crank); + ctx.strokeStyle = '#39415f'; + ctx.lineWidth = 4; + ctx.beginPath(); ctx.moveTo(hub.x, hub.y); ctx.lineTo(x - 2, y - 74); ctx.stroke(); // seat post + ctx.beginPath(); ctx.moveTo(hub.x, hub.y); ctx.lineTo(hub.x + 16, hub.y - 6); ctx.stroke(); // fork + ctx.lineWidth = 1; + // saddle + ctx.fillStyle = '#6b3a2a'; + ctx.beginPath(); ctx.ellipse(x - 4, y - 78, 16, 5, -0.06, 0, Math.PI * 2); ctx.fill(); + // pedals on the hub + const px = hub.x + Math.cos(crank * 2) * 15; + const py = hub.y + Math.sin(crank * 2) * 15; + const px2 = hub.x - Math.cos(crank * 2) * 15; + const py2 = hub.y - Math.sin(crank * 2) * 15; + ctx.strokeStyle = '#20242f'; + ctx.lineWidth = 3; + ctx.beginPath(); ctx.moveTo(px - 6, py); ctx.lineTo(px + 6, py); ctx.stroke(); + ctx.beginPath(); ctx.moveTo(px2 - 6, py2); ctx.lineTo(px2 + 6, py2); ctx.stroke(); + ctx.lineWidth = 1; + + const dip = duck * 18; + const bodyY = y - 100 + dip; + const bob = Math.sin(t * 10 + 1) * 1.4; + + // legs + ctx.strokeStyle = '#7a4e33'; + ctx.lineWidth = 6; + ctx.lineCap = 'round'; + ctx.beginPath(); ctx.moveTo(x - 6, bodyY + 14); ctx.quadraticCurveTo(x + 12, bodyY + 40, px, py); ctx.stroke(); + ctx.beginPath(); ctx.moveTo(x - 10, bodyY + 14); ctx.quadraticCurveTo(x + 6, bodyY + 44, px2, py2); ctx.stroke(); + ctx.lineWidth = 1; + ctx.lineCap = 'butt'; + + // tail + ctx.fillStyle = '#f2ecdd'; + ctx.beginPath(); ctx.arc(x - 32, bodyY - 2 + bob, 6, 0, Math.PI * 2); ctx.fill(); + + // body + ctx.fillStyle = '#8a5a3c'; + ctx.beginPath(); + ctx.ellipse(x - 8, bodyY + bob, 28, 17, -0.1, 0, Math.PI * 2); + ctx.fill(); + ctx.fillStyle = 'rgba(240,230,210,0.25)'; + ctx.beginPath(); + ctx.ellipse(x - 10, bodyY + 7 + bob, 22, 8, -0.1, 0, Math.PI); + ctx.fill(); + + // neck + head + const headX = x + 24 - duck * 12; + const headY = bodyY - 26 + dip * 1.6 + bob; + ctx.strokeStyle = '#8a5a3c'; + ctx.lineWidth = 11; + ctx.lineCap = 'round'; + ctx.beginPath(); + ctx.moveTo(x + 8, bodyY - 4 + bob); + ctx.quadraticCurveTo(x + 20 - duck * 12, bodyY - 16 + dip + bob, headX, headY); + ctx.stroke(); + ctx.lineWidth = 1; + ctx.lineCap = 'butt'; + ctx.fillStyle = '#8a5a3c'; + ctx.beginPath(); ctx.ellipse(headX + 4, headY + 2, 13, 9, 0.15, 0, Math.PI * 2); ctx.fill(); + // snout + ctx.fillStyle = '#6b4228'; + ctx.beginPath(); ctx.arc(headX + 14, headY + 4, 5, 0, Math.PI * 2); ctx.fill(); + ctx.fillStyle = '#20242f'; + ctx.beginPath(); ctx.arc(headX + 17, headY + 3, 1.8, 0, Math.PI * 2); ctx.fill(); // nose + ctx.beginPath(); ctx.arc(headX + 6, headY - 2, 2, 0, Math.PI * 2); ctx.fill(); // eye + // ear + ctx.fillStyle = '#7a4e33'; + ctx.beginPath(); ctx.ellipse(headX - 6, headY - 4, 6, 3, -0.6, 0, Math.PI * 2); ctx.fill(); + // antlers + ctx.strokeStyle = '#d9c9a3'; + ctx.lineWidth = 3; + ctx.lineCap = 'round'; + for (const s of [-1, 1]) { + const ax = headX - 2 + s * 4; + ctx.beginPath(); + ctx.moveTo(ax, headY - 7); + ctx.quadraticCurveTo(ax + s * 6, headY - 24, ax + s * 2, headY - 32); + ctx.stroke(); + ctx.beginPath(); ctx.moveTo(ax + s * 4, headY - 18); ctx.lineTo(ax + s * 13, headY - 24); ctx.stroke(); + ctx.beginPath(); ctx.moveTo(ax + s * 3, headY - 26); ctx.lineTo(ax + s * 11, headY - 33); ctx.stroke(); + } + // red nose glow (Rudolph tax) + const rg = ctx.createRadialGradient(headX + 17, headY + 3, 1, headX + 17, headY + 3, 12); + rg.addColorStop(0, 'rgba(255,60,60,0.55)'); + rg.addColorStop(1, 'rgba(255,60,60,0)'); + ctx.fillStyle = rg; + ctx.fillRect(headX + 5, headY - 9, 24, 24); + ctx.lineWidth = 1; + ctx.lineCap = 'butt'; +} + +export type CRenderingContext = CanvasRenderingContext2D; diff --git a/src/badge.ts b/src/badge.ts new file mode 100644 index 0000000..c81df86 --- /dev/null +++ b/src/badge.ts @@ -0,0 +1,56 @@ +// : the label in the top right corner, "Advent of AI Slop [Day 1] +// Living fishtank". Its first part links to the calendar, the rest to the door of the day this was made for. +// It draws itself in a shadow root, so its styles and the page's never touch. +const site = 'https://advent-of-slop.quesma.com'; + +const css = ` + nav { + position: fixed; + top: 0; + right: 0; + z-index: 2147483647; + display: flex; + flex-wrap: wrap; + gap: 0 0.35em; + max-width: 100vw; + box-sizing: border-box; + padding: 0.35rem 0.7rem; + border-bottom-left-radius: 0.5rem; + background: #b8232f; + font: 700 0.8125rem/1.2 system-ui, sans-serif; + } + a { + color: #f6ecd6; + text-decoration: none; + } + a:hover { + text-decoration: underline; + } +`; + +const link = (href: string, text: string): HTMLAnchorElement => { + const anchor = document.createElement('a'); + anchor.href = href; + anchor.textContent = text; + return anchor; +}; + +class AdventBadge extends HTMLElement { + connectedCallback(): void { + const day = Number(this.getAttribute('day')); + if (!Number.isInteger(day) || day < 1 || day > 24) { + throw new Error(` needs day="1" to day="24", got ${this.getAttribute('day')}`); + } + const name = this.getAttribute('name'); + if (name === null || name.trim() === '') { + throw new Error(' needs name="...", the title of its day, such as name="Living fishtank"'); + } + const style = document.createElement('style'); + style.textContent = css; + const label = document.createElement('nav'); + label.append(link(`${site}/`, 'Advent of AI Slop'), link(`${site}/day/${day}/`, `[Day ${day}] ${name}`)); + this.attachShadow({ mode: 'open' }).append(style, label); + } +} + +customElements.define('advent-badge', AdventBadge); diff --git a/src/game.ts b/src/game.ts new file mode 100644 index 0000000..ebd2eb7 --- /dev/null +++ b/src/game.ts @@ -0,0 +1,339 @@ +// Core game: world state, physics, spawning, collisions, rendering order. +import { + W, H, GROUND, + type Building, type Obstacle, type Pickup, type Flake, + makeBuilding, drawSky, drawBuildings, drawStreet, drawLamp, + drawObstacle, drawPickup, drawPelican, drawReindeer, +} from './art'; + +export type CharId = 'pelican' | 'reindeer'; +export type Phase = 'menu' | 'playing' | 'crashed' | 'paused'; + +interface CharSpec { + v0: number; accel: number; vmax: number; + jumpV: number; jumps: number; + standH: number; duckH: number; +} + +const SPECS: Record = { + pelican: { v0: 330, accel: 9, vmax: 700, jumpV: 980, jumps: 1, standH: 118, duckH: 66 }, + reindeer: { v0: 300, accel: 7, vmax: 640, jumpV: 850, jumps: 2, standH: 132, duckH: 62 }, +}; + +const GRAVITY = 2600; +const RIDER_X = 190; +const RIDER_W = 84; + +interface Rider { + y: number; // wheel-contact line + vy: number; + onGround: boolean; + jumpsLeft: number; + duck: number; // eased 0..1 + crank: number; // pedal angle + crashT: number; +} + +export interface HudState { + score: number; meters: number; kmh: number; fish: number; best: number; +} + +const rand = (a: number, b: number): number => a + Math.random() * (b - a); + +export class Game { + phase: Phase = 'menu'; + char: CharId = 'pelican'; + time = 0; + scroll = 0; + speed = 0; + pickupsGot = 0; + best = 0; + + private spec: CharSpec = SPECS.pelican; + private rider: Rider = this.freshRider(); + private far: Building[] = []; + private mid: Building[] = []; + private near: Building[] = []; + private lamps: number[] = []; + private obstacles: Obstacle[] = []; + private pickups: Pickup[] = []; + private flakes: Flake[] = []; + private distSinceSpawn = 1e9; + private distSincePickup = 0; + private garlandCooldown = 0; + private score = 0; + private onHud: (h: HudState) => void; + private onCrash: (score: number, meters: number, fish: number, best: number, isNewBest: boolean) => void; + + constructor(hud: (h: HudState) => void, crash: (s: number, m: number, f: number, b: number, n: boolean) => void) { + this.onHud = hud; + this.onCrash = crash; + this.buildLayer(); + let lx = 60; + while (lx < W + 300) { this.lamps.push(lx); lx += 300; } + for (let i = 0; i < 130; i++) { + this.flakes.push({ + x: Math.random() * W, y: Math.random() * H, + r: rand(1, 3), vy: rand(26, 70), sway: rand(10, 30), phase: Math.random() * Math.PI * 2, + }); + } + } + + private buildLayer(): void { + for (const [layer, list] of [[0, this.far], [1, this.mid], [2, this.near]] as const) { + let x = -40; + while (x < W + 200) { + const b = makeBuilding(x, layer); + list.push(b); + x += b.w + rand(6, 40); + } + } + } + + private freshRider(): Rider { + return { y: GROUND, vy: 0, onGround: true, jumpsLeft: 1, duck: 0, crank: 0, crashT: 0 }; + } + + setChar(c: CharId, best: number): void { + this.char = c; + this.spec = SPECS[c]; + this.best = best; + } + + start(): void { + this.phase = 'playing'; + this.time = 0; + this.scroll = 0; + this.speed = this.spec.v0; + this.rider = this.freshRider(); + this.rider.jumpsLeft = this.spec.jumps; + this.obstacles = []; + this.pickups = []; + this.pickupsGot = 0; + this.score = 0; + this.distSinceSpawn = 600; // first obstacle comes after a calm stretch + this.distSincePickup = 0; + this.garlandCooldown = 3; + } + + jump(): void { + if (this.phase !== 'playing') return; + const r = this.rider; + if (r.onGround) { + r.vy = -this.spec.jumpV; + r.onGround = false; + r.jumpsLeft = this.spec.jumps - 1; + } else if (r.jumpsLeft > 0) { + r.vy = -this.spec.jumpV * 0.88; + r.jumpsLeft -= 1; + } + } + + setDuck(on: boolean): void { + this.duckOn = on; + } + private duckOn = false; + + get crashDone(): boolean { return this.rider.crashT > 1.15; } + + pause(on: boolean): void { + if (on && this.phase === 'playing') this.phase = 'paused'; + else if (!on && this.phase === 'paused') this.phase = 'playing'; + } + + get meters(): number { return Math.floor(this.scroll / 40); } + get kmh(): number { return Math.round(this.speed * 0.065); } + get scoreNow(): number { return this.score; } + + update(dt: number): void { + this.time += dt; + // snow always falls, even in the menu + for (const f of this.flakes) { + f.y += f.vy * dt; + f.x -= (this.phase === 'playing' ? this.speed * 0.12 : 18) * dt + Math.sin(this.time * 2 + f.phase) * f.sway * dt; + if (f.y > H) { f.y = -4; f.x = Math.random() * W; } + if (f.x < -4) f.x = W + 4; + } + if (this.phase !== 'playing' && this.phase !== 'crashed') { this.pushHud(); return; } + + const r = this.rider; + if (this.phase === 'crashed') { + r.crashT += dt; + r.vy += GRAVITY * dt; + r.y = Math.min(GROUND, r.y + r.vy * dt); + return; + } + + // world speed ramps up + this.speed = Math.min(this.spec.vmax, this.spec.v0 + this.spec.accel * this.time); + const dx = this.speed * dt; + this.scroll += dx; + r.crank += dx * 0.045; + + // parallax layers recycle + const par = [0.22, 0.45, 0.72]; + for (const [i, list] of [[0, this.far], [1, this.mid], [2, this.near]] as const) { + for (const b of list) b.x -= dx * par[i]!; + let right = 0; + for (const b of list) right = Math.max(right, b.x + b.w); + for (const b of list) { + if (b.x + b.w < -60) { + b.x = right + rand(6, 40); + const nb = makeBuilding(b.x, i); + b.w = nb.w; b.h = nb.h; b.tone = nb.tone; b.seed = nb.seed; b.spire = nb.spire; + right = b.x + b.w; + } + } + } + // lamps at street speed + for (let i = 0; i < this.lamps.length; i++) { + this.lamps[i]! -= dx; + if (this.lamps[i]! < -40) this.lamps[i]! = Math.max(...this.lamps) + 300; + } + + // rider physics + const duckTarget = this.duckOn && r.onGround ? 1 : this.duckOn ? 0.5 : 0; + r.duck += (duckTarget - r.duck) * Math.min(1, dt * 14); + const g = this.duckOn && !r.onGround ? GRAVITY * 1.55 : GRAVITY; + r.vy += g * dt; + r.y += r.vy * dt; + if (r.y >= GROUND) { r.y = GROUND; r.vy = 0; r.onGround = true; r.jumpsLeft = this.spec.jumps; } + + // spawn obstacles by distance travelled + this.distSinceSpawn += dx; + const minGap = 240 + this.speed * 0.42; + if (this.distSinceSpawn > minGap * rand(0.85, 1.6)) { + this.distSinceSpawn = 0; + this.garlandCooldown -= 1; + const kinds: Obstacle['kind'][] = ['pothole', 'snowman', 'tree', 'gift', 'bin']; + if (this.garlandCooldown <= 0 && this.time > 12) { + this.garlandCooldown = 5; + this.obstacles.push({ kind: 'garland', x: W + 60, w: 230, h: 0, seed: Math.random() }); + } else { + const kind = kinds[Math.floor(Math.random() * kinds.length)]!; + const dims: Record = { + pothole: [64, 16], snowman: [40, 96], tree: [60, 92], gift: [46, 54], bin: [40, 66], + }; + const [w, h] = dims[kind]!; + this.obstacles.push({ kind, x: W + 60, w, h, seed: Math.random() }); + } + } + + // pickups: alternate ground-level and jump-height arcs + this.distSincePickup += dx; + if (this.distSincePickup > 200) { + this.distSincePickup = 0; + const kind = this.char === 'pelican' ? 'fish' : 'carrot'; + const high = Math.random() < 0.45; + const y = high ? GROUND - rand(120, 175) : GROUND - 30; + for (let i = 0; i < 3; i++) { + this.pickups.push({ + kind, x: W + 80 + i * 42, + y: high ? y - Math.sin((i / 2) * Math.PI) * 26 : y, + taken: false, + }); + } + } + + // move + collide + const riderTop = r.y - (this.spec.standH - (this.spec.standH - this.spec.duckH) * r.duck); + const riderLeft = RIDER_X - RIDER_W / 2; + const riderRight = RIDER_X + RIDER_W / 2 - 14; + for (const o of this.obstacles) { + o.x -= dx; + if (o.kind === 'garland') { + const top = GROUND - 150, bottom = GROUND - 70; + if (riderRight > o.x + 14 && riderLeft < o.x + o.w - 14 && riderTop < bottom && r.y > top) this.crash(); + } else if (o.kind !== 'pothole') { + const oTop = GROUND - o.h; + if (riderRight > o.x + 6 && riderLeft < o.x + o.w - 6 && r.y > oTop + 8) this.crash(); + } else { + // pothole: only punishes if the wheel is on the ground while over it + if (riderRight > o.x + 10 && riderLeft + 20 < o.x + o.w - 10 && r.onGround) this.crash(); + } + } + this.obstacles = this.obstacles.filter((o) => o.x + o.w > -80); + + for (const p of this.pickups) { + p.x -= dx; + if (!p.taken && Math.abs(p.x - RIDER_X) < 34 && Math.abs(p.y - (r.y - 70)) < 52) { + p.taken = true; + this.pickupsGot += 1; + this.score += 50; + } + } + this.pickups = this.pickups.filter((p) => p.x > -40); + + this.score = Math.max(this.score, 0); + this.score += dx * 0.1; // distance points trickle in + this.pushHud(); + } + + private crash(): void { + if (this.phase !== 'playing') return; + this.phase = 'crashed'; + this.rider.crashT = 0; + this.rider.vy = -420; + const finalScore = Math.floor(this.score); + const isNew = finalScore > this.best; + this.onCrash(finalScore, this.meters, this.pickupsGot, Math.max(this.best, finalScore), isNew); + } + + private pushHud(): void { + this.onHud({ + score: Math.floor(this.score), + meters: this.meters, + kmh: this.kmh, + fish: this.pickupsGot, + best: this.best, + }); + } + + render(ctx: CanvasRenderingContext2D): void { + drawSky(ctx, this.time); + drawBuildings(ctx, this.far, 0, this.time); + drawBuildings(ctx, this.mid, 1, this.time); + drawBuildings(ctx, this.near, 2, this.time); + drawStreet(ctx, this.scroll); + for (const lx of this.lamps) if (lx > -60 && lx < W + 60) drawLamp(ctx, lx, this.time); + for (const o of this.obstacles) if (o.kind === 'garland') drawObstacle(ctx, o, this.time); + for (const o of this.obstacles) if (o.kind !== 'garland') drawObstacle(ctx, o, this.time); + for (const p of this.pickups) drawPickup(ctx, p, this.time); + + // rider (with a crash tumble) + const r = this.rider; + ctx.save(); + if (this.phase === 'crashed') { + ctx.translate(RIDER_X, r.y - 60); + ctx.rotate(r.crashT * 5.2); + ctx.translate(-RIDER_X, -(r.y - 60)); + // impact stars + ctx.fillStyle = '#ffd166'; + for (let i = 0; i < 6; i++) { + const a = (i / 6) * Math.PI * 2 + r.crashT * 3; + const d = 40 + r.crashT * 60; + ctx.beginPath(); + ctx.arc(RIDER_X + Math.cos(a) * d, r.y - 70 + Math.sin(a) * d * 0.6, 4 - r.crashT * 2, 0, Math.PI * 2); + ctx.fill(); + } + } + if (this.char === 'pelican') drawPelican(ctx, RIDER_X, r.y, r.crank, r.duck, this.time); + else drawReindeer(ctx, RIDER_X, r.y, r.crank, r.duck, this.time); + ctx.restore(); + + // snow on top of everything + ctx.fillStyle = 'rgba(240,245,255,0.9)'; + for (const f of this.flakes) { + ctx.globalAlpha = 0.35 + f.r / 4; + ctx.beginPath(); ctx.arc(f.x, f.y, f.r, 0, Math.PI * 2); ctx.fill(); + } + ctx.globalAlpha = 1; + + // soft vignette + const v = ctx.createRadialGradient(W / 2, H / 2, H * 0.55, W / 2, H / 2, H * 1.05); + v.addColorStop(0, 'rgba(0,0,0,0)'); + v.addColorStop(1, 'rgba(5,8,18,0.5)'); + ctx.fillStyle = v; + ctx.fillRect(0, 0, W, H); + } +} diff --git a/src/main.ts b/src/main.ts new file mode 100644 index 0000000..cca6029 --- /dev/null +++ b/src/main.ts @@ -0,0 +1,119 @@ +import './style.css'; +import { Game, type CharId, type HudState } from './game'; + +const canvas = document.getElementById('game') as HTMLCanvasElement | null; +const maybeCtx = canvas?.getContext('2d'); +if (!canvas || !maybeCtx) throw new Error('canvas #game missing'); +const ctx: CanvasRenderingContext2D = maybeCtx; + +const el = (id: string): HTMLElement => { + const e = document.getElementById(id); + if (!e) throw new Error(`missing #${id}`); + return e; +}; + +const hudScore = el('hud-score'), hudDist = el('hud-dist'), hudSpeed = el('hud-speed'), + hudFish = el('hud-fish'), hudBest = el('hud-best'); +const menu = el('menu'), pauseOv = el('pause'), gameover = el('gameover'); +const finalScore = el('final-score'), finalDist = el('final-dist'), finalFish = el('final-fish'), + bestLine = el('best-line'), crashLine = el('crash-line'); + +const bestKey = (c: CharId): string => `aos5-best-${c}`; +const loadBest = (c: CharId): number => Number(localStorage.getItem(bestKey(c)) ?? '0') || 0; + +const game = new Game( + (h: HudState) => { + hudScore.textContent = String(h.score); + hudDist.textContent = String(h.meters); + hudSpeed.textContent = String(h.kmh); + hudFish.textContent = String(h.fish); + hudBest.textContent = String(h.best); + }, + (score, meters, fish, best, isNew) => { + finalScore.textContent = String(score); + finalDist.textContent = String(meters); + finalFish.textContent = String(fish); + if (isNew) { + localStorage.setItem(bestKey(game.char), String(best)); + bestLine.textContent = '★ new personal best!'; + bestLine.classList.add('new'); + } else { + bestLine.textContent = `best: ${best}`; + bestLine.classList.remove('new'); + } + const lines = game.char === 'pelican' + ? ['Squawk.', 'Honk. That was not a ramp.', 'The fish saw everything.'] + : ['Clatter.', 'The unicycle disagrees.', 'Rudolph needs a moment.']; + crashLine.textContent = lines[Math.floor(Math.random() * lines.length)]!; + gameover.classList.remove('hidden'); + hudBest.textContent = String(best); + }, +); + +function selectChar(c: CharId): void { + game.setChar(c, loadBest(c)); + hudBest.textContent = String(loadBest(c)); + game.start(); + menu.classList.add('hidden'); + gameover.classList.add('hidden'); +} + +for (const card of document.querySelectorAll('#cards .card')) { + card.addEventListener('click', () => { + const c = card.dataset['char']; + if (c === 'pelican' || c === 'reindeer') selectChar(c); + }); +} + +el('restart-btn').addEventListener('click', () => selectChar(game.char)); +el('menu-btn').addEventListener('click', () => { + gameover.classList.add('hidden'); + menu.classList.remove('hidden'); + game.phase = 'menu'; +}); + +const JUMP_KEYS = new Set(['Space', 'ArrowUp', 'KeyW']); +const DUCK_KEYS = new Set(['ArrowDown', 'KeyS']); + +window.addEventListener('keydown', (e) => { + if (e.repeat) return; + if (JUMP_KEYS.has(e.code)) { + e.preventDefault(); + if (game.phase === 'menu' && !menu.classList.contains('hidden')) return; // menu needs a pick + if (game.phase === 'crashed' && game.crashDone) selectChar(game.char); + game.jump(); + } else if (DUCK_KEYS.has(e.code)) { + e.preventDefault(); + game.setDuck(true); + } else if (e.code === 'KeyR' && (game.phase === 'crashed' || game.phase === 'playing')) { + selectChar(game.char); + } else if (e.code === 'KeyP' || e.code === 'Escape') { + game.pause(game.phase === 'playing'); + pauseOv.classList.toggle('hidden', game.phase !== 'paused'); + } else if (game.phase === 'menu' && !menu.classList.contains('hidden')) { + if (e.code === 'Digit1') selectChar('pelican'); + if (e.code === 'Digit2') selectChar('reindeer'); + } +}); +window.addEventListener('keyup', (e) => { + if (DUCK_KEYS.has(e.code)) game.setDuck(false); +}); + +canvas.addEventListener('pointerdown', (e) => { + e.preventDefault(); + if (game.phase === 'playing') game.jump(); +}); + +// main loop +let last = performance.now(); +function frame(now: number): void { + const dt = Math.min(0.033, (now - last) / 1000); + last = now; + game.update(dt); + game.render(ctx); + requestAnimationFrame(frame); +} +requestAnimationFrame(frame); + +// expose for the smoke test +(window as unknown as Record)['__aos5'] = game; diff --git a/src/style.css b/src/style.css new file mode 100644 index 0000000..db18a8b --- /dev/null +++ b/src/style.css @@ -0,0 +1,156 @@ +:root { + --bg: #10131f; + --panel: #1b2032; + --ink: #f2ecdd; + --dim: #9aa3bd; + --accent: #ffb648; + --red: #b8232f; + --green: #2f7d5c; +} + +* { box-sizing: border-box; } + +body { + margin: 0; + background: + radial-gradient(1200px 500px at 50% -10%, #232c4a 0%, transparent 60%), + var(--bg); + color: var(--ink); + font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; +} + +#app { + max-width: 1240px; + margin: 0 auto; + padding: 1.2rem 1rem 2.5rem; +} + +header { text-align: center; margin-bottom: 0.6rem; } + +h1 { + margin: 0; + font-size: clamp(1.6rem, 4vw, 2.4rem); + letter-spacing: 0.02em; +} +h1::after { content: " 🚲"; } + +.tagline { margin: 0.15rem 0 0; color: var(--dim); font-style: italic; } + +#hud { + display: flex; + flex-wrap: wrap; + justify-content: center; + gap: 0.45rem; + margin: 0.7rem 0 0.8rem; +} + +.chip { + background: var(--panel); + border: 1px solid #2c3450; + border-radius: 999px; + padding: 0.25rem 0.8rem; + font-size: 0.85rem; + color: var(--dim); +} +.chip b { color: var(--ink); font-variant-numeric: tabular-nums; } +.chip.best b { color: var(--accent); } + +#stage { + position: relative; + border-radius: 14px; + overflow: hidden; + border: 1px solid #2c3450; + box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45); + background: #0b0e18; +} + +canvas { + display: block; + width: 100%; + height: auto; +} + +.overlay { + position: absolute; + inset: 0; + display: flex; + align-items: center; + justify-content: center; + background: rgba(10, 13, 24, 0.62); + backdrop-filter: blur(3px); +} +.overlay.hidden { display: none; } + +.panel { + background: var(--panel); + border: 1px solid #39415f; + border-radius: 14px; + padding: 1.4rem 1.8rem; + text-align: center; + max-width: 640px; + box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5); +} + +.panel h2 { margin: 0 0 0.9rem; font-size: 1.5rem; } + +#cards { display: flex; gap: 0.8rem; justify-content: center; flex-wrap: wrap; } + +.card { + display: flex; + flex-direction: column; + gap: 0.3rem; + width: 250px; + padding: 0.9rem 1rem; + background: #232a42; + color: var(--ink); + border: 1px solid #39415f; + border-radius: 12px; + cursor: pointer; + font: inherit; + text-align: center; + transition: transform 0.12s, border-color 0.12s; +} +.card:hover { transform: translateY(-3px); border-color: var(--accent); } +.card .glyph { font-size: 1.9rem; } +.card b { font-size: 1.02rem; } +.card small { color: var(--dim); } + +.controls { color: var(--dim); font-size: 0.88rem; margin: 1rem 0 0; } + +kbd { + background: #2c3450; + border: 1px solid #465074; + border-bottom-width: 2px; + border-radius: 5px; + padding: 0.05em 0.45em; + font: 0.8em ui-monospace, monospace; +} + +.score-line { margin: 0.2rem 0; font-size: 1.05rem; } +.score-line b { color: var(--accent); font-size: 1.3rem; } +.best-line { color: var(--dim); margin: 0.2rem 0 1rem; min-height: 1.2em; } +.best-line.new { color: var(--accent); font-weight: 700; } + +#restart-btn, #menu-btn { + font: inherit; + border-radius: 10px; + padding: 0.5rem 1.1rem; + cursor: pointer; + margin: 0 0.3rem; +} +#restart-btn { + background: var(--red); + border: 1px solid #d4374a; + color: #fff; + font-weight: 700; +} +#restart-btn:hover { filter: brightness(1.15); } +#menu-btn { background: transparent; border: 1px solid #465074; color: var(--dim); } +#menu-btn:hover { color: var(--ink); } + +.hint { + text-align: center; + color: var(--dim); + font-size: 0.85rem; + margin: 0.8rem 0 0; +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..8b42ef2 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + "target": "ES2023", + "module": "ESNext", + "moduleResolution": "bundler", + "lib": ["ES2023", "DOM", "DOM.Iterable"], + "types": ["vite/client"], + "strict": true, + "noUncheckedIndexedAccess": true, + "verbatimModuleSyntax": true, + "skipLibCheck": true, + "noEmit": true + }, + "include": ["src"] +} diff --git a/vite.config.ts b/vite.config.ts new file mode 100644 index 0000000..08e54d3 --- /dev/null +++ b/vite.config.ts @@ -0,0 +1,6 @@ +import { defineConfig } from 'vite'; + +export default defineConfig({ + // Relative links, so the build works under https://.github.io// whatever the repository is called. + base: './', +});