I'll create a Don't Starve-like 2D survival game using Three.js with procedurally generated sprites. Let me start by exploring the project structure.
Now let me plan the game architecture. I'll create:
- A
SpriteGenerator that procedurally generates 2D pixel-art textures (character, trees, rocks, grass, etc.)
- A
World class for tile-based terrain generation with noise
- A
Game class managing Three.js scene, player, day/night cycle, hunger, health
- A React App that mounts the game
Let me start building. First, update the index.html title and main CSS:
Now the core: a procedurally generated sprite/texture system using OffscreenCanvas/Canvas2D. I'll generate pixel-art for character, trees, rocks, grass, twigs, etc.
Let me fix the unused-variable TS errors. I'll use a small helper to mark the unused r so TS is happy.
Let me look at the current file and fix things more carefully. There are several r references that got removed but are still used. Let me read the relevant sections.
Now I see all the issues. Let me fix them all in one go — re-add the r declarations where they're used and remove truly unused ones.
Only 1 issue left. Let me fix line 199 properly.
All sprite generator errors fixed. Now let me build the world generator and the main game engine. This is the biggest part:
Now the main Game class that wires Three.js together with the world, player, and rendering:
Fix the type errors:
Let me find and fix the remaining two errors:
For the Sprite issue, the actual problem is line 535 — the shadowed tex variable name conflicts with the imported tex() helper. Let me fix both:
The TypeScript narrowing isn't picking up that k is a key of the object. Let me look at line 800:
inv is Entity["inventory"] (the same shape), but TS still doesn't trust it because of the optional tInv type. Let me type both:
Now there's one more thing I need to handle: I render the ground as part of the scene.background color but I never actually draw the ground tiles. The grass tiles need to be visible. Let me add a ground group that holds ground tile sprites. Let me also check the current state:
I need to add ground tile rendering. Let me add a ground group with grass sprites, and rebuild logic:
Let me add a ground tile layer. I'll add a groundGroup with grass tiles, and modify rebuildSprites to manage them too. Let me find a good place to add the field:
The first edit failed. Let me retry:
Now let me also fix the dispose calls that I changed (removed .map?.dispose() for the decoration map). Sprites share textures, so disposing the texture would break other sprites. The current version is correct. Now let me create the React App and HUD:
Now wire the HUD into App.tsx:
Now let me build the project to see if there are any remaining issues:
Build succeeded. But I should review the game for a few important runtime issues:
- The
keyHover method is weird and shouldn't exist - I added a typo earlier. Let me clean it up.
- The
mobSprites cleanup uses id which is a generated string - if I assign it via ??= it should be stable.
- The
Ground color in the scene background is only visible if no ground tiles cover it.
Let me also check the moveEntity function — there's a subtle bug where I update nx then check against e.y for x collision, but if the player is in the middle of a tile (not 0.5 offset), they could get stuck. Let me check:
Movement is fine. Let me also remove the typo method and tidy up:
Now there's a real gameplay issue: spiders can spawn right on top of objects. Let me also check that the tex helper import isn't shadowed by tex as a property name in the tex object. I have this.tex = { ... } which is fine. But in buildTextures, I wrote this.tex.tree = makeTree(1) && tex(makeTree(1)); which calls makeTree once and then once more — wasteful. Let me fix:
Let me also verify a subtle bug in interact — when toggling the campfire, I check inv.cooked first, but if the campfire is currently off (unlit) the user might still want to interact to light it. Let me check:
Good. Let me also build a final time to ensure everything still compiles:
The project builds successfully. Let me also verify one more runtime concern — I'm using frameTime in spider update which is fine. Let me also verify that the tex parameter for s.userData set on the campfire sprite is OK — I'm not actually reading it anywhere, so it's harmless.
Let me do a final summary by reading the top of the App:
Build is clean. Here's a summary of what I built:
🎮 Hollow Creek — A Don't Starve-like Survival Game
Files created:
src/game/SpriteGenerator.ts — Procedural pixel-art generator that draws every sprite from scratch on <canvas> using ImageData (no external image assets):
- Wilson-style player (2-frame walk cycle)
- Tree, bush, rock, grass, twig, sapling, berry, spider, campfire, chest, torch (some animated, with seeded variation)
- Animated water tile + grass/sand ground tiles
src/game/World.ts — Tile-based world with simplex-noise biomes, sparse chunked storage, walkability queries, light-radius queries from campfires/torches.
src/game/Game.ts — The Three.js engine:
- Orthographic 2D camera that follows the player
- Streaming decoration sprites built/destroyed as the player moves (no overdraw)
- Day/night cycle with a custom shader that darkens the screen and reveals a soft halo around lit campfires/torches
- Hunger, HP, sanity survival stats, spider AI (wander / aggro / attack), inventory, gathering, chopping, mining, cooking, attacking, placing campfires/torches/chests
src/ui/HUD.tsx — React HUD: hearts, hunger bell, sanity, day counter, day/night progress bar, inventory bar with hotkey labels, center messages, Game Over screen, and an intro help modal.
index.html / src/index.css / src/App.tsx — Updated title and global styles for crisp pixel rendering.
Controls: WASD/arrows to move, E to gather/use, F to attack, Space to eat, 1/2/3 to place campfire/torch/chest. Build successfully verified.
Files built: index.html, src/index.css, src/game/SpriteGenerator.ts, src/game/World.ts, src/game/Game.ts, src/ui/HUD.tsx, src/App.tsx