Lively Minds
Organization
Playpower LabsRole
Web Game DeveloperTeam Size
1Duration
2 MonthsTech Stack
Phaser • React • TailwindCSS • Google Gemini
A 2D exploratory game where players interact with AI-powered philosophers, scientists, and poets. The project focuses on scalable gameplay architecture, NPC behavior systems, and real-time AI-driven conversations.
Key Contributions
NPC State Machine System · Gameplay AI · System Design
- Designed and implemented a modular finite state machine (FSM) to control NPC behavior in a scalable and maintainable way.
- Defined a strict
IStatecontract to enforce consistency across all states (onEnter,onUpdate,onExit). - Centralized state transitions in a reusable
StateMachinecontroller, keeping states isolated and single-responsibility. - Used explicit state enums and event enums to make transitions predictable, debuggable, and designer-friendly.
- Implemented event-driven transitions (interaction, timeouts, collisions) instead of hard-coded condition chains.
- Integrated movement, animation triggers, and timing logic at the state level while keeping the core engine agnostic.
- Designed the system to be future-ready, allowing new states to be added without modifying the core.
Code: IState Contract
1export interface IState { 2 stateName: StateEnum; 3 onEnter(): void; 4 onUpdate(deltaTime: number): void; 5 onExit(): void; 6} 7 8export enum StateEnum { 9 IDLE = "idle", 10 WALK = "walk", 11 DANCE = "dance", 12 TALK = "talk", 13 READ = "read", 14 WRITE = "write", 15} 16 17export enum StateEvent { 18 WALK_REQUESTED = "walkRequested", 19 TALK_REQUESTED = "talkRequested", 20 BOOK_COLLISION = "bookCollision", 21 WRITE_REQUESTED = "writeRequested", 22 TIMEOUT = "timeout", 23}
Code: StateMachine Controller
1import { IState } from "./IState";
2
3export class StateMachine<S extends string, E extends string> {
4 private transitions: Record<S, Partial<Record<E, S>>>;
5 private states: Map<S, IState>;
6 private currentState: S | null = null;
7
8 constructor(transitions: Record<S, Partial<Record<E, S>>>) {
9 this.transitions = transitions;
10 this.states = new Map();
11 }
12
13 addState(state: IState & { stateName: S }): this {
14 this.states.set(state.stateName, state);
15 return this;
16 }
17
18 setInitialState(state: S): void {
19 this.setState(state);
20 }
21
22 private setState(newState: S): void {
23 if (this.currentState === newState) return;
24
25 if (this.currentState) this.states.get(this.currentState)?.onExit();
26 this.currentState = newState;
27 this.states.get(this.currentState)?.onEnter();
28 }
29
30 updateState(deltaTime: number): void {
31 if (!this.currentState) return;
32 this.states.get(this.currentState)?.onUpdate(deltaTime);
33 }
34
35 handleEvent(event: E): void {
36 if (!this.currentState) return;
37
38 const next = this.transitions[this.currentState]?.[event];
39 if (!next) return;
40
41 if (next !== this.currentState) this.setState(next);
42 }
43
44 getCurrentState(): S | null {
45 return this.currentState;
46 }
47}
NPC Factory & Data-Driven Spawning · Tooling · Content Pipelines
- Implemented an NPC factory that spawns NPCs using JSON-driven configuration.
- Defined NPC identity, metadata, sprites, and ideas via external data files.
- Supported random placement while handling collisions between NPCs, player, and world.
- Included fallback NPC definitions to handle data or asset failures.
1[ 2 { 3 "name": "Pythagoras", 4 "dates": "570–495 BCE", 5 "about": "Pythagoras was an ancient Greek philosopher and mathematician best known for the Pythagorean theorem.", 6 "image": "assets/Pythagoras/front_breathe1.png", 7 "keyIdeas": ["Everything is number"], 8 "quote": "Number rules the universe." 9 } 10]
Player–NPC Interaction System · UX · Interaction Design
- Implemented hover, focus, and click-based interactions.
- Displayed contextual UI elements such as NPC name banners and metadata panels.
- Enabled players to initiate conversations directly from the world.
- Allowed players to join ongoing NPC-to-NPC conversations.
AI-Powered NPC Chat Backend · Systems Design · Scalability
- Built a backend chat service using FastAPI.
- Integrated Gemini as the LLM provider.
- Supported single-NPC and multi-NPC conversations.
- Preserved NPC identity and context across group dialogues.
- Designed the API to be stateless and horizontally scalable.
Modular Animation System · Reusability · SOLID Design
- Built a shared animation abstraction used by both NPCs and the player.
- Implemented a base animation interface to standardize playback, transitions, and layering.
- Supported flat and layered animation strategies.
- Decoupled animation logic from gameplay and state logic.
- Designed the system to scale from simple NPCs to complex characters.
End-to-End Project Integration · Solo Development · Full Stack
- Created the complete project solo, covering gameplay, UI, and backend systems.
- Integrated the game canvas (Phaser) with the UI layer (React + Tailwind CSS) into a cohesive experience.
- Used free assets for rapid iteration, with select custom sprite sheets for key NPCs.