feat: add dynamic ship tracking for sentences mode
- Ship now moves to center of each character as you type - Calculate and store X position of current character during rendering - Ship smoothly tracks typing progress across both lines - Handles line transitions seamlessly - Creates engaging targeting effect as ship 'shoots' each letter
This commit is contained in:
+11
-4
@@ -28,7 +28,7 @@ export function useGame(
|
||||
gameStatusManager.updatePlayerX(playerPos.x);
|
||||
|
||||
// For words/letters, auto-track to falling letters
|
||||
// For sentences/paragraphs, keep ship centered
|
||||
// For sentences/paragraphs, track to current character position
|
||||
if (gameModeRef.current !== 'sentences' && gameModeRef.current !== 'paragraphs') {
|
||||
if (letters.length > 0) {
|
||||
const letter = letters[0];
|
||||
@@ -37,9 +37,16 @@ export function useGame(
|
||||
|
||||
cursorManager.moveTowardTarget(deltaTime);
|
||||
} else {
|
||||
// Keep ship centered for sentence/paragraph mode
|
||||
cursorManager.setTargetX(400); // Canvas center
|
||||
cursorManager.moveTowardTarget(deltaTime); // Move to center but don't track letters
|
||||
// For sentences: track to current character position
|
||||
if (letters.length > 0) {
|
||||
const letter = letters[0];
|
||||
// Use the stored character position or default to center
|
||||
const targetX = letter.currentCharX || 400;
|
||||
cursorManager.setTargetX(targetX);
|
||||
} else {
|
||||
cursorManager.setTargetX(400); // Default to center when no letters
|
||||
}
|
||||
cursorManager.moveTowardTarget(deltaTime);
|
||||
}
|
||||
|
||||
renderBoardWrapped(letters);
|
||||
|
||||
Reference in New Issue
Block a user