feat: implement falling letters spawning from top

- Letters spawn at random horizontal positions every 1 second
- Letters fall at 100px/second from top to bottom
- Random A-Z letters rendered in white monospace font
- Fix game loop to start properly when startGame called
- Remove letters that exit bottom of screen
This commit is contained in:
2025-11-03 22:01:40 +00:00
parent dce96b8453
commit 0dc4ecde72
4 changed files with 85 additions and 19 deletions
+10 -1
View File
@@ -25,7 +25,7 @@ export function useBoard() {
canvasRef.current = canvas;
}, []);
const renderBoard = (playerPosition: PlayerPosition) => {
const renderBoard = (playerPosition: PlayerPosition, letters: any = []) => {
const canvas = canvasRef.current;
if (!canvas) return;
@@ -72,6 +72,15 @@ export function useBoard() {
ctx.lineTo(spaceshipX + 8, spaceshipY + 15);
ctx.closePath();
ctx.fill();
// Draw falling letters
ctx.fillStyle = "#ffffff";
ctx.font = "24px monospace";
ctx.textAlign = "center";
ctx.textBaseline = "top";
letters.forEach((letter: any) => {
ctx.fillText(letter.letter, letter.x, letter.y);
});
};
return {