8234530ed745b7538bd4f1e5baa420185ca6ebf8
Dominoes Online
A modern, real-time multiplayer dominoes game built with Next.js, TypeScript, Canvas, and Socket.IO.
Features
- 🎮 Real-time Multiplayer - Play with friends online using WebSocket connections
- 🤖 AI Opponent - Play against an intelligent AI when no other players are available
- 🎨 Beautiful UI - Modern, responsive design with smooth animations
- 🎯 Canvas Rendering - Domino tiles rendered using HTML5 Canvas
- 📱 Responsive - Works great on desktop and mobile devices
- ⚡ Fast & Real-time - Instant updates for all players
How to Play
- Create a Room - Start a new game and share the room code with friends
- Join a Room - Enter a room code to join an existing game
- Play vs AI - Practice against an AI opponent
- Match Tiles - Place tiles that match the numbers on the board ends
- Win - First player to use all tiles wins!
Game Rules
- Each player starts with 7 domino tiles
- Players take turns placing tiles that match the numbers on either end of the board
- If you can't play, draw a tile from the boneyard
- The game ends when a player uses all their tiles or when no one can move
- Lowest total value wins if the game is blocked
Tech Stack
- Next.js 16 - React framework for production
- TypeScript - Type-safe JavaScript
- Socket.IO - Real-time bidirectional communication
- Zustand - State management
- Framer Motion - Smooth animations
- Tailwind CSS - Utility-first CSS framework
- HTML5 Canvas - Tile rendering
Getting Started
Prerequisites
- Node.js 18+ installed
- npm or yarn package manager
Installation
- Install dependencies:
npm install
- Run the custom server with Socket.IO:
npm run dev
- Open http://localhost:3000 in your browser
Note: This project uses a custom Next.js server (server.mjs) to integrate Socket.IO for real-time multiplayer functionality.
Development
Project Structure
domino/
├── app/ # Next.js app directory
│ ├── api/socket/ # Socket.IO API route
│ ├── page.tsx # Main game page
│ └── layout.tsx # Root layout
├── components/ # React components
│ ├── DominoCanvas.tsx
│ ├── GameBoard.tsx
│ ├── PlayerHand.tsx
│ ├── Lobby.tsx
│ ├── WaitingRoom.tsx
│ └── GameOver.tsx
├── lib/ # Core game logic
│ ├── types.ts # TypeScript interfaces
│ ├── gameLogic.ts # Game mechanics
│ ├── aiLogic.ts # AI opponent
│ ├── store.ts # Zustand store
│ └── socket-server.ts # Socket.IO server
└── public/ # Static assets
Available Scripts
npm run dev- Start custom development server with Socket.IOnpm run build- Build for productionnpm start- Start production server with Socket.IOnpm run lint- Run ESLint
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT License - feel free to use this project for learning or personal use.
Enjoy playing dominoes online! 🎲
Descripción
Languages
TypeScript
85.3%
JavaScript
14.3%
CSS
0.4%