Skip to content

Add dialogue system, critters, NPCs, and new areas to Kingdom#25

Open
jordangarrison wants to merge 6 commits into
mainfrom
claude/beautiful-shannon-0bqhs7
Open

Add dialogue system, critters, NPCs, and new areas to Kingdom#25
jordangarrison wants to merge 6 commits into
mainfrom
claude/beautiful-shannon-0bqhs7

Conversation

@jordangarrison

Copy link
Copy Markdown
Owner

This PR significantly expands the Kingdom game with a full dialogue and quest system, ambient critters, NPC wandering AI, and three new explorable areas (beach, berry woods, bakery).

Summary

The Kingdom now features a complete conversation system with character personalities, friendship tracking, and fetch-quest errands. NPCs wander their home areas, critters (butterflies, bees, birds, etc.) animate the world, and players can pick up ground items and complete quests to deepen relationships.

Key Changes

Dialogue & Quests

  • New dialogue.ts module with all conversation content: greetings, personality chatter, contextual flavor lines, and quest templates
  • DialoguePanel.svelte component for rendering conversations with typewriter effect, character portraits, and heart-based friendship display
  • Quest system with templates for fetch errands (collect items, return for rewards)
  • Context-aware dialogue that responds to inventory, location, and friendship level

Character Sprites

  • New sprites.ts module with pixel-art character rendering (Jane, Isla, Ollie, Mommy, Daddy)
  • Sprites drawn entirely with fillRect on an 18×18 grid, supporting multiple views (up/down/side), walk cycles, blinking, and idle bobbing
  • Player character gets a soft glow effect; all sprites cast shadows

Critters & Ambient Life

  • New critters.ts module for ambient creatures: butterflies, bees, petals, dragonflies, birds
  • Critters wander between anchor tiles (flowers, water, etc.) with smooth steering and edge-nudging
  • Per-session simulation (never persisted); respawn when caught or leave the area

NPC AI & Wandering

  • NPCs now wander within configurable ranges from their home positions
  • Simple think-and-move AI with collision detection against tiles, decor, ground items, and other NPCs
  • NPCs sort by Y-coordinate for proper depth rendering

New Areas

  • Beach (with dock tiles, palm trees, sandcastles, dune grass)
  • Berry Woods (with berry bushes, new ground items)
  • Bakery (with oven, counter, table, rug, bookshelf tiles)

Ground Items & Pickups

  • GroundItem type replaces the old WildTulip system
  • Configurable spawn definitions with lifetime (persistent or temporary)
  • Items can be picked up and added to inventory

Rendering Improvements

  • Refactored draw() to accept a single DrawArgs object for cleaner signatures
  • Added helper functions for tile details (wood floor seams, sand texture, pixel circles for rugs)
  • Proper depth sorting: tiles → plots → ground items → decor → doors → sprites (sorted by Y) → critters
  • New tile types rendered with appropriate detail and color

Type System Expansion

  • Added CharacterId type for type-safe NPC references
  • New types: Critter, GroundItem, GroundSpawnDef, CritterKind, ActiveQuest, Friendship
  • Expanded TileKind with new terrain and furniture types
  • SaveState now tracks active quests and friendship levels per NPC

Game Loop Integration

  • NPC movement and critter updates integrated into main game tick
  • Dialogue pauses player movement; SPACE advances pages
  • Quest completion triggers rewards and friendship increases
  • Proper cleanup of dialogue state on area transitions

Notable Implementation Details

  • Dialogue uses Math.random() for pseudo-random but stable selection within a call
  • Critters use waypoint-based wandering with smooth steering for natural motion
  • Sprites scale with tile size (36px default) via a unit multiplier
  • NPC collision detection prevents overlap and respects plot boundaries
  • Friendship system caps at MAX_HEARTS (5) with persistent storage

https://claude.ai/code/session_01SHPKH43kQPii8zrCEy251v

claude added 6 commits June 9, 2026 20:39
…orld

Expands the kingdom's shared contracts and game engine toward an Animal
Crossing / Stardew Valley feel:

- types.ts: 3 new areas (beach, berry-woods, bakery), new tiles (fence,
  dock, palm, oven, rug...), 4 new items (berry, shell, butterfly,
  muffin), friendship hearts, fetch-errand quests, ambient critters,
  data-driven ground-item spawners, save v2
- save.ts: v1 -> v2 migration so existing saves keep their progress
- plots.ts: berry bushes that regrow like lavender
- KingdomGame.svelte: NPC wander AI, dialogue/quest state machine with
  rewards and heart gains, butterfly catching, shell collecting, muffin
  baking, furniture flavor text, sfx, smarter HUD with errand tracker

Pixel sprites, dialogue content/panel, new maps and critter simulation
land in the follow-up commit.

https://claude.ai/code/session_01SHPKH43kQPii8zrCEy251v
- areas.ts: courtyard reworked into a fountain plaza with paths to all
  7 doors; dock on the pond; cozier cottage (rug, table, bookshelf);
  fences and flower accents throughout; three new areas wired in:
  pond -> Beach Cove (shells, palms, sandcastle), rose garden ->
  Berry Woods (8 berry bushes, catchable butterflies), courtyard ->
  Sweet Bakery (oven, counter cafe). Legacy plot ids and coordinates
  preserved for old saves; module-load integrity assertion guards
  every map's dimensions.
- critters.ts: gentle wandering butterflies, bees, drifting petals,
  water-skimming dragonflies, and fly-over birds with repopulation,
  plus butterflyAt() hit-testing for catching.

https://claude.ai/code/session_01SHPKH43kQPii8zrCEy251v
Background agents are still finishing the pixel-sprite module, renderer
rewrite, and dialogue panel; this snapshot keeps the branch in sync.
Final integration commit follows.

https://claude.ai/code/session_01SHPKH43kQPii8zrCEy251v
- dialogue.ts: per-NPC voices with first-meeting intros, greeting
  variants across three friendship tiers, family chatter with gameplay
  tips, contextual flavor reactions to what the player carries, and 20
  fetch-errand quest templates (4 per family member) with thematic
  rewards. Lines about a family member are filtered when the player is
  playing as them.
- DialoguePanel.svelte: bottom-anchored conversation panel with an
  animated pixel-sprite portrait, name plate, friendship hearts,
  24ms/char typewriter text, page-advance indicators, and tap/click
  to advance.

https://claude.ai/code/session_01SHPKH43kQPii8zrCEy251v
…tion

- render.ts/sprites.ts: final art-pass versions (the earlier WIP
  snapshots captured these mid-edit).
- Playtesting found that holding a direction key through the
  courtyard <-> bakery doors bounced the player back and forth
  forever: both landings sit in the travel direction of the return
  door. Clear held movement input on every area transition instead —
  you now stop in the doorway of each new area, which also gives kids
  a beat to see where they've arrived.
- Persist v1 saves immediately after migrating (one-shot upgrade).
- Lint cleanup: fix empty-arrow eslint error, prettier-format the
  kingdom module including pre-existing TextBubble drift.

https://claude.ai/code/session_01SHPKH43kQPii8zrCEy251v
@vercel

vercel Bot commented Jun 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
tots Ready Ready Preview, Comment Jun 9, 2026 9:22pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants