diff --git a/Web_Based_Ubuntu_Linux/app/src/apps/Pong.tsx b/Web_Based_Ubuntu_Linux/app/src/apps/Pong.tsx index 4bb838a..27ddb7e 100644 --- a/Web_Based_Ubuntu_Linux/app/src/apps/Pong.tsx +++ b/Web_Based_Ubuntu_Linux/app/src/apps/Pong.tsx @@ -99,12 +99,15 @@ export default function Pong() { // Move paddles const paddleSpeed = 6; - if (keys.current['w'] || keys.current['W']) leftPaddle.current.y = Math.max(0, leftPaddle.current.y - paddleSpeed); - if (keys.current['s'] || keys.current['S']) leftPaddle.current.y = Math.min(CANVAS_H - PADDLE_H, leftPaddle.current.y + paddleSpeed); - + + if (keys.current['KeyW']) {leftPaddle.current.y = Math.max(0, leftPaddle.current.y - paddleSpeed);} + + if (keys.current['KeyS']) {leftPaddle.current.y = Math.min(CANVAS_H - PADDLE_H, leftPaddle.current.y + paddleSpeed);} + if (modeRef.current === '2p') { - if (keys.current['ArrowUp']) rightPaddle.current.y = Math.max(0, rightPaddle.current.y - paddleSpeed); - if (keys.current['ArrowDown']) rightPaddle.current.y = Math.min(CANVAS_H - PADDLE_H, rightPaddle.current.y + paddleSpeed); + if (keys.current['ArrowUp']) {rightPaddle.current.y = Math.max(0, rightPaddle.current.y - paddleSpeed);} + + if (keys.current['ArrowDown']) {rightPaddle.current.y = Math.min(CANVAS_H - PADDLE_H, rightPaddle.current.y + paddleSpeed);} } else { // AI const diff = aiDiffRef.current; @@ -238,24 +241,31 @@ export default function Pong() { // Keyboard useEffect(() => { const handleKeyDown = (e: KeyboardEvent) => { - keys.current[e.key] = true; - if (e.key === ' ' && gameStateRef.current === 'playing' && waitingForServe.current) { + keys.current[e.code] = true; + + if (e.code === 'Space' && gameStateRef.current === 'playing' && waitingForServe.current) { e.preventDefault(); waitingForServe.current = false; } - if ((e.key === 'p' || e.key === 'P') && gameStateRef.current === 'playing') { - setGameState('paused'); - gameStateRef.current = 'paused'; - } else if ((e.key === 'p' || e.key === 'P') && gameStateRef.current === 'paused') { - setGameState('playing'); - gameStateRef.current = 'playing'; + + if (e.code === 'KeyP') { + if (gameStateRef.current === 'playing') { + setGameState('paused'); + gameStateRef.current = 'paused'; + } else if (gameStateRef.current === 'paused') { + setGameState('playing'); + gameStateRef.current = 'playing'; + } } }; + const handleKeyUp = (e: KeyboardEvent) => { - keys.current[e.key] = false; + keys.current[e.code] = false; }; + window.addEventListener('keydown', handleKeyDown); window.addEventListener('keyup', handleKeyUp); + return () => { window.removeEventListener('keydown', handleKeyDown); window.removeEventListener('keyup', handleKeyUp); diff --git a/Web_Based_Ubuntu_Linux/app/src/apps/registry.ts b/Web_Based_Ubuntu_Linux/app/src/apps/registry.ts index b285e50..5962af8 100644 --- a/Web_Based_Ubuntu_Linux/app/src/apps/registry.ts +++ b/Web_Based_Ubuntu_Linux/app/src/apps/registry.ts @@ -187,7 +187,7 @@ export const APP_REGISTRY: AppDefinition[] = [ icon: 'MessageSquare', category: 'Internet', description: 'Instant messaging interface', - defaultSize: { width: 480, height: 600 }, + defaultSize: { width: 580, height: 600 }, minSize: { width: 320, height: 400 }, }, { @@ -234,7 +234,7 @@ export const APP_REGISTRY: AppDefinition[] = [ icon: 'Music', category: 'Media', description: 'Audio player with playlist and visualization', - defaultSize: { width: 520, height: 440 }, + defaultSize: { width: 520, height: 600 }, minSize: { width: 360, height: 320 }, }, { @@ -326,7 +326,7 @@ export const APP_REGISTRY: AppDefinition[] = [ icon: 'X', category: 'Games', description: '2-player and AI tic-tac-toe', - defaultSize: { width: 400, height: 440 }, + defaultSize: { width: 400, height: 490 }, minSize: { width: 280, height: 320 }, }, { @@ -335,7 +335,7 @@ export const APP_REGISTRY: AppDefinition[] = [ icon: 'Hash', category: 'Games', description: 'Number sliding puzzle', - defaultSize: { width: 400, height: 480 }, + defaultSize: { width: 400, height: 530 }, minSize: { width: 320, height: 400 }, }, {