Conversation
…snow/particle fixes
…torms; compact debug status gated by debug flag
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
Extracts biome selection/data into a dedicated module and extends biome rendering with place/time + weather variants, while updating the build pipeline to bundle the new script.
Changes:
- Added
src/biome.jsand updated runtime to source biome state viawindow.BIOME_MODULE.getCurBiome(dist). - Added a debug-only compact status line and desert cactus / arctic snow visuals in
game.js. - Updated
build.shto concatenatebiome.js+game.jsbefore minification and adjusted the generated HTML output.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| src/index.html | Ensures biome.js loads before game.js in the unbundled (src) version. |
| src/game.js | Switches biome selection to BIOME_MODULE, adds debug status line and new biome-specific visuals. |
| src/biome.js | New global BIOME_MODULE providing biome selection, blending, and deterministic weather flags. |
| build.sh | Bundles biome+game JS into a single minified payload and emits a minimal HTML wrapper. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| elif [ "$HAS_BUN" -eq 1 ]; then | ||
| bun build "$JS_SRC" --minify --target=browser --outfile "$JS_TMP" >/dev/null | ||
| # bun build accepts multiple inputs but to be safe concat first | ||
| cat "${JS_SRC_LIST[@]}" > "$JS_TMP" && bun build "$JS_TMP" --minify --target=browser --outfile "$JS_TMP" >/dev/null || true | ||
| else |
There was a problem hiding this comment.
The bun branch concatenates into $JS_TMP and also uses the same $JS_TMP as the bun build --outfile, while also appending || true. Writing the output to the same file being read is error-prone, and || true can silently ship an unminified/partial bundle if bun fails. Use a separate input/output temp file and let the script fail on bun build errors.
| e.preventDefault();return; | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
There’s trailing whitespace on this blank line. Consider removing it to avoid noisy diffs and keep formatting clean.
| /* Biome module extracted from game.js | ||
| Exposes window.BIOME_MODULE.getCurBiome(dist) which returns a biome object | ||
| compatible with the previous in-file representation. It also deterministically | ||
| randomizes per-cycle weather flags (cloudy, starsOn, snowOn) so you can get | ||
| cloudy/clear day/sunset/night/winter variations. | ||
| */ | ||
| function hexToRgb(h){const n=parseInt(h.slice(1),16);return[n>>16,(n>>8)&255,n&255];} | ||
| function lC(a,b,t){return'rgb('+(a[0]+(b[0]-a[0])*t|0)+','+(a[1]+(b[1]-a[1])*t|0)+','+(a[2]+(b[2]-a[2])*t|0)+')';} | ||
| function lN(a,b,t){return a+(b-a)*t} |
There was a problem hiding this comment.
src/biome.js defines helper functions (hexToRgb/lC/lN) and constants in the global scope. Since src/game.js also defines functions with the same names, this can lead to accidental global collisions/overwrites depending on script load order. Wrap biome.js in an IIFE (like game.js) and only export the intended API via window.BIOME_MODULE.
| // readable biome names (order should match BIOME_MODULE.BIOMES) | ||
| const BIOME_NAMES = ['Temperate','Autumn','Night','Winter','Desert']; |
There was a problem hiding this comment.
BIOME_NAMES is declared but never used. Since BIOME_MODULE now generates many place/time combinations, this hard-coded list is also misleading; consider removing it or deriving names from BIOME_MODULE.PLACES/TIMES if you still need a label list.
| // readable biome names (order should match BIOME_MODULE.BIOMES) | |
| const BIOME_NAMES = ['Temperate','Autumn','Night','Winter','Desert']; |
| }; | ||
| const particles=[]; | ||
| let snowParticles=[]; | ||
| let sandParticles=[]; |
There was a problem hiding this comment.
sandParticles is now only cleared (sandstorms are removed) and never otherwise used. Consider deleting this array entirely (and the related clear logic) to keep the render loop simpler, or reintroduce sand rendering if it’s still intended.
| let sandParticles=[]; | |
| let sandParticles=[]; | |
| // Expose a trivial read usage so sandParticles is not write-only; kept side-effect free. | |
| function getSandParticleCount(){ | |
| return sandParticles.length|0; | |
| } |
| const dist=Math.max(0,Math.floor((player.x-startX)/10)); | ||
| calcBiome(dist); | ||
| // Select current biome based on player distance | ||
| curBiome = (window.BIOME_MODULE && window.BIOME_MODULE.getCurBiome) ? window.BIOME_MODULE.getCurBiome(dist) : curBiome; | ||
| const B=curBiome; |
There was a problem hiding this comment.
Biome selection is now recomputed every render() call via getCurBiome(dist). The previous in-file calcBiome() had a small-distance cache to avoid repeated work when dist changes slowly, which can matter on mobile. Consider adding caching (either in biome.js or here) so getCurBiome only runs when dist changes by some threshold.
| JS_SRC_LIST=("$BIOME_SRC" "$GAME_SRC") | ||
| JS_TMP="${BUILD_DIR}/game.build.tmp.js" | ||
| INDEX_OUT="${BUILD_DIR}/index.html" | ||
| JS_TMP="${BUILD_DIR}/game.build.tmp.js" |
There was a problem hiding this comment.
JS_TMP is assigned twice to the same path. This is harmless but redundant and can be confusing when editing the script; remove the duplicate assignment.
| JS_TMP="${BUILD_DIR}/game.build.tmp.js" |
No description provided.