From 0c515caee01390e53961041fc73c3702c7f27aef Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sat, 17 Jan 2026 07:42:37 +0000 Subject: [PATCH] Changes --- src/pages/Games.tsx | 2 +- src/pages/Pacman.tsx | 36 +++++++++++++++++++++++++++--------- src/pages/Snake.tsx | 37 +++++++++++++++++++++---------------- src/pages/Tetris.tsx | 34 +++++++++++++++++----------------- 4 files changed, 66 insertions(+), 43 deletions(-) diff --git a/src/pages/Games.tsx b/src/pages/Games.tsx index 1855cb4..6c2920d 100644 --- a/src/pages/Games.tsx +++ b/src/pages/Games.tsx @@ -44,7 +44,7 @@ const games = [ id: 'breakout', name: 'Breakout', description: 'Break bricks with a bouncing ball', - hasMultiplayer: true, + hasMultiplayer: false, ascii: `┌────────┐ │████████│ │▓▓▓▓▓▓▓▓│ diff --git a/src/pages/Pacman.tsx b/src/pages/Pacman.tsx index 68cb448..b200b0e 100644 --- a/src/pages/Pacman.tsx +++ b/src/pages/Pacman.tsx @@ -477,40 +477,58 @@ const Pacman = () => { // Player 1 controls (WASD and Arrow keys) - immediate response switch (e.key) { - case 'ArrowUp': case 'w': case 'W': + // In 2P mode, P1 uses WASD only; in 1P mode, use both WASD and Arrows + case 'ArrowUp': + e.preventDefault(); + if (gameMode === '1p' && !player1Eliminated) setNextDirection('up'); + break; + case 'ArrowDown': + e.preventDefault(); + if (gameMode === '1p' && !player1Eliminated) setNextDirection('down'); + break; + case 'ArrowLeft': + e.preventDefault(); + if (gameMode === '1p' && !player1Eliminated) setNextDirection('left'); + break; + case 'ArrowRight': + e.preventDefault(); + if (gameMode === '1p' && !player1Eliminated) setNextDirection('right'); + break; + case 'w': case 'W': e.preventDefault(); if (!player1Eliminated) setNextDirection('up'); break; - case 'ArrowDown': case 's': case 'S': + case 's': case 'S': e.preventDefault(); if (!player1Eliminated) setNextDirection('down'); break; - case 'ArrowLeft': case 'a': case 'A': + case 'a': case 'A': e.preventDefault(); if (!player1Eliminated) setNextDirection('left'); break; - case 'ArrowRight': case 'd': case 'D': + case 'd': case 'D': e.preventDefault(); if (!player1Eliminated) setNextDirection('right'); break; } - // Player 2 controls (IJKL keys) - only in 2P mode + // Player 2 controls (Arrow keys) - only in 2P mode + // P1 uses WASD, P2 uses Arrow keys if (gameMode === '2p') { switch (e.key) { - case 'i': case 'I': + case 'ArrowUp': e.preventDefault(); if (!player2Eliminated) setNextDirection2('up'); break; - case 'k': case 'K': + case 'ArrowDown': e.preventDefault(); if (!player2Eliminated) setNextDirection2('down'); break; - case 'j': case 'J': + case 'ArrowLeft': e.preventDefault(); if (!player2Eliminated) setNextDirection2('left'); break; - case 'l': case 'L': + case 'ArrowRight': e.preventDefault(); if (!player2Eliminated) setNextDirection2('right'); break; diff --git a/src/pages/Snake.tsx b/src/pages/Snake.tsx index 613a77e..bf9c6bf 100644 --- a/src/pages/Snake.tsx +++ b/src/pages/Snake.tsx @@ -45,7 +45,7 @@ const Snake = () => { // Multiplayer state const [players, setPlayers] = useState<[Player, Player]>([ { snake: [{ x: 5, y: 10 }], direction: 'right', score: 0, alive: true, color: 'hsl(var(--primary))', name: 'P1' }, - { snake: [{ x: 15, y: 10 }], direction: 'left', score: 0, alive: true, color: 'hsl(280 70% 50%)', name: 'P2' }, + { snake: [{ x: 15, y: 10 }], direction: 'left', score: 0, alive: true, color: 'hsl(var(--secondary))', name: 'P2' }, ]); const [food2P, setFood2P] = useState({ x: 10, y: 10 }); const [winner, setWinner] = useState(null); @@ -198,7 +198,7 @@ const Snake = () => { const p2Start = [{ x: 15, y: 10 }]; setPlayers([ { snake: p1Start, direction: 'right', score: 0, alive: true, color: 'hsl(var(--primary))', name: 'P1' }, - { snake: p2Start, direction: 'left', score: 0, alive: true, color: 'hsl(280 70% 50%)', name: 'P2' }, + { snake: p2Start, direction: 'left', score: 0, alive: true, color: 'hsl(var(--secondary))', name: 'P2' }, ]); currentDirections2P.current = ['right', 'left']; directionQueues2P.current = [[], []]; @@ -448,11 +448,11 @@ const Snake = () => { style.backgroundColor = players[0].color; style.opacity = 0.8; } else if (isP2Head) { - bgClass = 'border-purple-500'; + bgClass = 'border-secondary'; style.backgroundColor = players[1].color; style.boxShadow = `0 0 10px ${players[1].color}`; } else if (isP2 && players[1].alive) { - bgClass = 'border-purple-500/60'; + bgClass = 'border-secondary/60'; style.backgroundColor = players[1].color; style.opacity = 0.8; } else if (isFood) { @@ -507,10 +507,10 @@ const Snake = () => { {!isMobile && ( )} @@ -543,7 +543,7 @@ const Snake = () => {

- Snake {gameMode === '2p' && 2P} + Snake {gameMode === '2p' && 2P}

+
+ + BACK + + +
)} diff --git a/src/pages/Tetris.tsx b/src/pages/Tetris.tsx index ba728b9..b3566bb 100644 --- a/src/pages/Tetris.tsx +++ b/src/pages/Tetris.tsx @@ -29,13 +29,13 @@ const TETROMINOS = { }; const TETROMINOS_P2 = { - I: { shape: [[1, 1, 1, 1]], color: 'hsl(280 70% 50%)' }, - O: { shape: [[1, 1], [1, 1]], color: 'hsl(280 70% 50%)' }, - T: { shape: [[0, 1, 0], [1, 1, 1]], color: 'hsl(280 70% 50%)' }, - S: { shape: [[0, 1, 1], [1, 1, 0]], color: 'hsl(280 70% 50%)' }, - Z: { shape: [[1, 1, 0], [0, 1, 1]], color: 'hsl(280 70% 50%)' }, - J: { shape: [[1, 0, 0], [1, 1, 1]], color: 'hsl(280 70% 50%)' }, - L: { shape: [[0, 0, 1], [1, 1, 1]], color: 'hsl(280 70% 50%)' }, + I: { shape: [[1, 1, 1, 1]], color: 'hsl(var(--secondary))' }, + O: { shape: [[1, 1], [1, 1]], color: 'hsl(var(--secondary))' }, + T: { shape: [[0, 1, 0], [1, 1, 1]], color: 'hsl(var(--secondary))' }, + S: { shape: [[0, 1, 1], [1, 1, 0]], color: 'hsl(var(--secondary))' }, + Z: { shape: [[1, 1, 0], [0, 1, 1]], color: 'hsl(var(--secondary))' }, + J: { shape: [[1, 0, 0], [1, 1, 1]], color: 'hsl(var(--secondary))' }, + L: { shape: [[0, 0, 1], [1, 1, 1]], color: 'hsl(var(--secondary))' }, }; type TetrominoKey = keyof typeof TETROMINOS; @@ -519,9 +519,9 @@ const Tetris = () => { Solo mode {!isMobile && ( - )} @@ -542,7 +542,7 @@ const Tetris = () => {

- Tetris {gameMode === '2p' && 2P} + Tetris {gameMode === '2p' && 2P}