feat: add collision detection between falling letters and ship

- Detect collisions when letters reach ship's Y position
- Both letter and ship explode with particle animations on collision
- Ship explosion displays expanding particles in yellow, orange, and red
- Letters explode with their existing animation system
- After collision, letters clear and new letter spawns automatically
- Game continues after collision (no game-over condition yet)
- Collision threshold tuned for reliable detection (30px from ship center)
- Added shipState tracking to GameStatusManager
- Ship position continuously synced during game loop
This commit is contained in:
2025-11-03 22:57:41 +00:00
parent d69a9a6cc9
commit 08c2d40d23
4 changed files with 186 additions and 95 deletions
+6
View File
@@ -21,6 +21,7 @@ export const getGamePhase = (status: GameStatus): GamePhase =>
export type PlayerPosition = { x: number }; // pixel position 0-800
export type LetterState = 'normal' | 'wrong' | 'exploding';
export type ShipState = 'normal' | 'exploding';
export type FallingLetter = {
id: string;
@@ -95,6 +96,11 @@ export type GameStatusManager = {
level: number;
score: number;
togglePause: () => void;
shipState: ShipState;
shipExplosionTime: number;
updatePlayerX: (x: number) => void;
handleTypedLetter: (letter: string) => void;
setGameLoopCallback: (callback: (deltaTime: number, letters: FallingLetter[]) => void) => void;
};
// ============================================================================