TwoPlayerGames
Trò chơi đối kháng 2 người — chơi chung máy, đấu AI hoặc online qua mã phòng. HTML/CSS/JS thuần + Node WebSocket.
TwoPlayerGames is a self-hosted collection of 47 two-player browser games, classics like Connect Four, Battleship, and Yahtzee, playable locally at one keyboard or online with a friend using a room code.
TwoPlayerGames is a self-hosted collection of 47 two-player games that you run on your own computer. The README is written in Vietnamese. Players can sit together at one keyboard (called hot-seat mode) or play from two separate machines over a local network or the internet. The entire game logic runs in the browser using plain HTML, CSS, and JavaScript, while a small Node.js server handles hosting the page and relaying moves between players over a live connection.
The game list covers a wide range of types. Classic board games include Connect Four, Reversi, Checkers, Battleship, Mancala, Pentago, Quoridor, and several varieties of gomoku-style grid games. There are dice games such as Yahtzee, Pig, and Domino, card-style games like Auction War, and action games including Pong, a billiards game, and a slingshot game. Several games are designed for hidden-information play and work only in online mode, where each player sees a different view of the board.
Online play works through a four-digit room code. One player creates a room and shares the code; the other player enters it to join. The server relays moves between the two browsers. An in-room chat panel lets players send messages or quick preset phrases, and sound effects signal moves, wins, and incoming chat. Some games let both players agree on custom settings before starting, such as board size or winning conditions, and those settings sync between the two machines automatically.
To run it locally you need Node.js version 18 or higher. Three terminal commands install dependencies, start the server, and open the app in a browser at port 8777. A built-in test script checks JavaScript syntax, verifies the game registry, and runs a quick server and connection test. Playing over the internet beyond a local network requires a tool like ngrok to expose your local server to the outside world.
Where it fits
- Host a collection of classic board and dice games on your own computer for two people to play at the same keyboard.
- Play games like Connect Four, Battleship, or Yahtzee online with a remote friend using a four-digit room code.
- Extend the collection by adding your own two-player browser game to the existing server and game registry.