feat: implement game modes system with letters and words support
- Add GameMode type: 'letters' | 'words' | 'sentences' | 'paragraphs' - Add gameMode option to GameOptions (defaults to 'letters') - Create wordLists.ts with curated word lists for each mode - Update FallingLetter type to track: - fullText: complete word/sentence/paragraph - charIndex: current character progress in word - Modify word spawning to pick from mode-specific word list - Update handleTypedLetter to support multi-character typed sequences: - Track progress through word (charIndex) - Advance to next character when correct - Show complete word only when fully typed - Enhanced canvas rendering with color-coded progress: - Green: completed characters - Yellow: current character being typed - White: remaining characters - Add mode selector buttons to example app - Default to 'words' mode in example for testing - Full TypeScript support for all modes
This commit is contained in:
+5
-1
@@ -7,6 +7,7 @@ import type { RefObject } from 'react';
|
||||
export type GameStatus = 'waiting' | 'started' | 'game-won' | 'game-over';
|
||||
export type GamePhase = 'idle' | 'playing';
|
||||
export type PlayStatus = 'started' | 'game-over' | 'game-won';
|
||||
export type GameMode = 'letters' | 'words' | 'sentences' | 'paragraphs';
|
||||
|
||||
export const isPlaying = (status: GameStatus): status is PlayStatus =>
|
||||
status === 'started' || status === 'game-over' || status === 'game-won';
|
||||
@@ -30,6 +31,9 @@ export type FallingLetter = {
|
||||
y: number; // 0-600 pixel position
|
||||
state: LetterState;
|
||||
stateStartTime?: number; // For animation timing
|
||||
// For word/sentence/paragraph modes
|
||||
fullText?: string; // The complete word/sentence/paragraph
|
||||
charIndex?: number; // Current character index being typed (0-based)
|
||||
};
|
||||
|
||||
// ============================================================================
|
||||
@@ -39,7 +43,7 @@ export type FallingLetter = {
|
||||
export type KeyLogEntry = { key: string; timestamp: number };
|
||||
|
||||
export type GameOptions = {
|
||||
// TODO: Define game options
|
||||
gameMode?: GameMode;
|
||||
};
|
||||
|
||||
// ============================================================================
|
||||
|
||||
Reference in New Issue
Block a user