A real-time multiplayer memory card game built with React, Logux, and featuring Peppa Pig characters. Players can collaborate to find matching pairs, with live cursor tracking and synchronized game state across all connected clients.
- Real-time Multiplayer: Multiple players can play simultaneously with synchronized game state
- Live Cursor Tracking: See other players' mouse cursors in real-time
- Drag & Drop: Cards can be moved around the game board
- Responsive Design: Works on both desktop and mobile devices with touch support
- Animated Card Flips: Smooth 3D card flip animations using Framer Motion
- Auto-shuffle: Automatically shuffle cards when all pairs are found
- Sound Effects: Audio feedback for matching pairs
- Character Matching: Features beloved Peppa Pig characters
- React 19 - UI framework
- TypeScript - Type safety
- Tailwind CSS - Styling and responsive design
- Framer Motion - Animations and transitions
- React DnD - Drag and drop functionality
- Nanostores - State management
- Vite - Build tool and development server
- Logux Server - Real-time synchronization
- Node.js - Server runtime
- WebSocket - Real-time communication
- ESLint - Code linting
- Prettier - Code formatting
- TypeScript compiler - Type checking
The game implements a classic memory card matching game with the following mechanics:
- Card Grid: 32 cards arranged in a 4x8 grid (16 unique character pairs)
- Flip Mechanism: Click cards to flip them face-up
- Matching Logic: Two flipped cards are checked for character match
- Auto-Hide: Non-matching cards automatically flip back after 1 second
- Pair Tracking: Matched pairs remain face-up and are marked as found
- Win Condition: Game completes when all pairs are found
- Shuffle Feature: Cards can be reshuffled for a new game
- Cards Store (
src/stores/cards.ts
): Manages card positions, states, and matching logic - Cursors Store (
src/stores/cursors.ts
): Tracks other players' cursor positions - Logux Integration (
src/logux.ts
): Handles real-time synchronization
- Game State: Server maintains authoritative game state
- Action Processing: Handles card flips, moves, and match validation
- Real-time Broadcasting: Synchronizes state changes across all clients
- Shuffle System: Randomizes card positions while maintaining game integrity
- Canvas: Main game board with drop zone functionality
- Card: Individual card component with drag/flip interactions
- Cursor: Real-time cursor display for other players
- CustomDragLayer: Mobile-friendly drag preview
- Node.js 18+
- npm or yarn
- Clone the repository:
git clone <repository-url>
cd logux-card-app
- Install dependencies:
npm install
- Start the development server:
npm run dev
This command will start both the Logux server (port 31337) and the Vite development server with hot reload.
npm run dev
- Start both the Logux server and Vite development server with hot reloadnpm run server
- Start only the Logux server
- Start the Game: Open the application in your browser
- Flip Cards: Click on cards to flip them face-up
- Find Matches: Try to find matching character pairs
- Move Cards: Drag cards to rearrange them on the board
- Multiplayer: Share the URL with friends to play together
- Shuffle: When all pairs are found, use the shuffle button to start a new game
src/
├── components/ # React components
│ ├── Canvas.tsx # Main game board
│ ├── Card.tsx # Individual card component
│ ├── Cursor.tsx # Cursor display
│ └── CustomDragLayer.tsx
├── stores/ # Nanostores state management
│ ├── cards.ts # Card state
│ └── cursors.ts # Cursor tracking
├── utils/ # Utility functions
│ ├── canvas.ts # Canvas calculations
│ ├── deviceDetection.ts
│ └── sound.ts # Audio handling
├── types.ts # TypeScript definitions
└── logux.ts # Logux client configuration
server.js
- Logux server with game logicsrc/App.tsx
- Main application componentsrc/logux.ts
- Client-side Logux configurationpackage.json
- Dependencies and scripts
- New Card Actions: Add action types to
src/types.ts
and implement handlers inserver.js
- UI Components: Create new components in
src/components/
- Game Logic: Modify server-side logic in
server.js
- Styling: Use Tailwind CSS classes for consistent styling
- Add character images to
public/
folder - Update the
INITIAL_CARDS
array inserver.js
- Ensure each character has exactly 2 cards for proper pairing
- Grid Size: Adjust card positions in
INITIAL_CARDS
- Flip Delay: Modify timeout in
checkForMismatchedPairs()
- Match Logic: Update character comparison in server actions
npm run build
The application requires both a static file server for the frontend and a Node.js server for the Logux backend:
- Frontend: Deploy
dist/
folder to any static hosting service - Backend: Deploy
server.js
to a Node.js hosting platform - Configuration: Update Logux server URL in client configuration
PORT
- Server port (default: 31337)HOST
- Server host (default: 0.0.0.0)
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is open source and available under the MIT License.
- Character images and sound effects: AI generated based on Peppa Pig franchise
- Built with ❤️ using modern web technologies