feat: implement sentences mode with centered text and slower speed

- Set sentence fall speed to 25 pixels/second
- Replace sentences with longer, realistic ones including commas and punctuation
- Sentences always render centered on screen (80% max width constraint)
- Ship stays centered during sentence mode (no horizontal movement)
- Add punctuation support (. , ! ?) to keyboard input
- Disable auto-tracking for sentence/paragraph modes
This commit is contained in:
2025-11-04 17:00:20 +00:00
parent 68078e1ec7
commit 166ccd7783
5 changed files with 46 additions and 25 deletions
+8 -2
View File
@@ -2,7 +2,12 @@ import { useState, useRef } from "react";
import type { GameStatus, FallingLetter, ShipState, GameMode } from "../types";
import { getRandomWord } from "../wordLists";
const LETTER_SPEED = 100; // pixels per second
const LETTER_SPEEDS: Record<GameMode, number> = {
letters: 100,
words: 50,
sentences: 25,
paragraphs: 50,
};
const SPAWN_INTERVAL = 1000; // ms between letter spawns
const MAX_ACTIVE_LETTERS = 1; // Only one letter on screen at a time
const MARGIN_LEFT = 50; // Safe margin from left edge
@@ -53,8 +58,9 @@ export function useGameStatus(onGameLoopTick?: (deltaTime: number, letters: Fall
}
// Update letter positions
const speed = LETTER_SPEEDS[gameModeRef.current];
lettersRef.current.forEach(letter => {
letter.y += (LETTER_SPEED * deltaTime) / 1000;
letter.y += (speed * deltaTime) / 1000;
});
// Check for collisions with ship