Wapuu easter egg: lazy sprite loading#3287
Merged
sejas merged 1 commit intoeaster-egg-wapuu-platformerfrom Apr 30, 2026
Merged
Conversation
Contributor
I'm not convinced - pressing the key for some time doesn't seem like cheat codes should work. What if we removed this part completely and left the Konami code as the only way? This feels ever more fun to me. I'm happy to merge the resource loading part. |
Member
Author
|
Ok! I'll remove the long press modifications and merge the loading part. |
Convert module-level `const sprites = { ... }` into a lazy
`getSprites()` singleton so importers (e.g. wapuu-score.tsx pulling
MAX_SCORE through game-loop.ts) don't fire 10 image network requests
at module evaluation. Sprites now load on first render call inside
startGame().
cfd5174 to
29a46ad
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issues
Follow-up to #3270 addressing two review findings:
renderer.tsinstantiates 10Imageobjects at module top level.wapuu-score.tsximportsMAX_SCOREfromgame-loop.ts, which transitively importsrenderer.ts, so opening Settings → Account fires 10 sprite network requests for users who never play.Proposed Changes
apps/studio/src/modules/wapuu-world/engine/renderer.tsConvert module-level
const sprites = { ... }to a lazygetSprites()singleton. The 9sprites.foocall sites updated togetSprites().foo. Staticimport bgFarUrl from '...png'lines stay (Vite resolves these to URL strings at build time, no network cost) — only thenew Image(); .src = urlpair is now deferred until the first render call insidestartGame().Testing Instructions
Lazy sprite loading
npm start. Open DevTools → Network tab. Clear log. Filter bywapuu.wapuu-player-idle-sprite.pngloads (the score icon — direct import inwapuu-score.tsx). The other 9 sprite PNGs (wapuu-bg-far.png,wapuu-bg-near.png,wapuu-gutenberg-sprite.png,wapuu-mguy-sprite.png,wapuu-flag-sprite.png,wapuu-wave-sprite.png,wapuu-sprites-coin.png,wapuu-sprites-tiles.png,wapuu-player-sprite.png) must not appear.Pre-merge Checklist