A modern web implementation of the classic 2048 game with additional features like custom board sizes, dark theme, and game sharing capabilities.
- Customizable Board Size: Play with board sizes from 3x3 to 8x8
- Theme Support: Light and dark theme options
- Game Sharing:
- Share game link with others
- Generate and download game state images
- Multiple Control Options:
- Keyboard arrows
- Touch swipe gestures
- Mouse/touch controls
- Persistent Game State:
- Games saved on server
- Unique game IDs
- URL-based game loading
- Responsive Design:
- Works on desktop and mobile
- Adapts to different screen sizes
- Browser Features:
- History navigation support
- Theme preference saving
- Frontend:
- HTML5
- CSS3
- Vanilla JavaScript
- Backend:
- Node.js
- Express.js
- Canvas API for image generation
- Clone the repository:
git clone https://github.com/yourusername/koga-2048.git
cd koga 2048
- Install dependencies:
npm install
- Start the server:
npm start
- Open in browser:
http://localhost:3000
POST /api/games
- Create new game
Request body: { "size": 4 }
GET /api/games/:gameId
- Get game statePOST /api/games/:gameId/move
- Make a move
Request body: { "direction": "up" | "down" | "left" | "right" }
DELETE /api/games/:gameId
- Delete game
- GET /api/games/:gameId/image - Generate game board image
Query parameters:
- theme: "light" | "dark"
- ↑ (Up Arrow): Move up
- ↓ (Down Arrow): Move down
- ← (Left Arrow): Move left
- → (Right Arrow): Move right
- Swipe up: Move up
- Swipe down: Move down
- Swipe left: Move left
- Swipe right: Move right
- Fork the repository
- Create a feature branch
- Commit changes
- Push to the branch
- Create a Pull Request
MIT License
- feel free to use and modify for your projects
- Original 2048 game by Gabriele Cirulli
- Node.js and Express.js communities