Flip9 - Multiplayer Memory Game
A multiplayer memory card game where players take turns flipping cards in numerical order from 1 to 9. The game allows two players to play together from different devices.
Features
- Real-time multiplayer gameplay without WebSockets
- Vercel-compatible implementation using Vercel KV as the datastore
- Share a link to invite friends to play
- Mobile-responsive design
How to Play
- The first player creates a game and shares the link with a friend
- The second player joins by clicking the link
- Players take turns flipping cards, looking for numbers 1 through 9 in sequence
- If a player flips an incorrect card, their turn ends, and they start again from 1
- The first player to find 9 wins the game
Tech Stack
- Next.js 14 (App Router)
- TypeScript
- Tailwind CSS
- Vercel KV (for state management)
- SWR (for data fetching and polling)
Local Development
First, install dependencies:
npm install
# or
yarn
You'll need Vercel KV for the multiplayer functionality. You can use a local Redis instance for development:
- Create a new Vercel project and add a KV database
- Get your KV credentials from the Vercel Dashboard
- Copy
src/env.local.example
to .env.local
and add your KV credentials
Then run the development server:
npm run dev
# or
yarn dev
Visit http://localhost:3000 to play the game locally.
Deployment
The easiest way to deploy is with Vercel:
- Push your code to a Git repository
- Create a new project in Vercel and link it to your repository
- Add your KV credentials to the Environment Variables in the Vercel dashboard
- Deploy
How Multiplayer Works
This game uses a polling-based approach instead of WebSockets for Vercel compatibility:
- Game state is stored in Vercel KV
- Players poll for updates to the game state every 2 seconds
- When a player makes a move, they update the game state in KV
- The opponent receives the updated state on the next poll
This approach allows for near real-time gameplay without requiring WebSockets, making it compatible with Vercel's serverless architecture.
License
MIT