| <!DOCTYPE html> |
| <html lang="en"> |
| <head> |
| <meta charset="UTF-8"> |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| <title>Go Game</title> |
| <style> |
| * { |
| margin: 0; |
| padding: 0; |
| box-sizing: border-box; |
| } |
| |
| body { |
| display: flex; |
| flex-direction: column; |
| align-items: center; |
| min-height: 100vh; |
| background-image: url('Go.jpg'); |
| background-size: cover; |
| background-position: center; |
| background-repeat: no-repeat; |
| font-family: Arial, sans-serif; |
| padding: 20px; |
| } |
| |
| .game-container { |
| background: rgba(222, 184, 135, 0.9); |
| padding: 20px; |
| border-radius: 10px; |
| box-shadow: 0 0 20px rgba(0,0,0,0.3); |
| } |
| |
| |
| .board { |
| display: grid; |
| grid-template-columns: repeat(19, 30px); |
| grid-template-rows: repeat(19, 30px); |
| gap: 0px; |
| background: #DEB887; |
| border: 2px solid #000; |
| position: relative; |
| } |
| |
| .intersection { |
| width: 30px; |
| height: 30px; |
| position: relative; |
| cursor: pointer; |
| } |
| |
| .intersection::before { |
| content: ''; |
| position: absolute; |
| top: 50%; |
| left: 0; |
| width: 100%; |
| height: 1px; |
| background: #000; |
| } |
| |
| .intersection::after { |
| content: ''; |
| position: absolute; |
| left: 50%; |
| top: 0; |
| height: 100%; |
| width: 1px; |
| background: #000; |
| } |
| |
| .stone { |
| position: absolute; |
| width: 26px; |
| height: 26px; |
| border-radius: 50%; |
| top: 2px; |
| left: 2px; |
| z-index: 1; |
| transition: all 0.2s ease; |
| } |
| |
| .black { |
| background: #000; |
| box-shadow: 2px 2px 2px rgba(0,0,0,0.2); |
| } |
| |
| .white { |
| background: #fff; |
| box-shadow: 2px 2px 2px rgba(0,0,0,0.2); |
| } |
| |
| .controls { |
| margin-top: 20px; |
| display: flex; |
| gap: 10px; |
| } |
| |
| button { |
| padding: 10px 20px; |
| font-size: 16px; |
| border: none; |
| border-radius: 5px; |
| cursor: pointer; |
| background: #4CAF50; |
| color: white; |
| transition: background 0.3s; |
| } |
| |
| button:hover { |
| background: #45a049; |
| } |
| |
| .score { |
| margin-top: 20px; |
| font-size: 18px; |
| display: flex; |
| gap: 20px; |
| color: white; |
| text-shadow: 2px 2px 4px rgba(0,0,0,0.5); |
| } |
| |
| .mode-select { |
| margin-bottom: 20px; |
| } |
| |
| select { |
| padding: 8px; |
| font-size: 16px; |
| border-radius: 5px; |
| } |
| </style> |
| </head> |
| <body> |
| <audio id="stoneSoundEffect" src="BGM.mp4"></audio> |
| |
| <div class="mode-select"> |
| <select id="gameMode"> |
| <option value="pvp">Player vs Player</option> |
| <option value="ai">Player vs AI</option> |
| </select> |
| </div> |
|
|
| <div class="game-container"> |
| <div class="board" id="board"></div> |
| </div> |
|
|
| <div class="score"> |
| <div>Black Score: <span id="blackScore">0</span></div> |
| <div>White Score: <span id="whiteScore">0</span></div> |
| </div> |
|
|
| <div class="controls"> |
| <button id="passBtn">Pass</button> |
| <button id="resetBtn">Reset</button> |
| </div> |
|
|
| <script> |
| class GoGame { |
| constructor() { |
| this.size = 19; |
| this.board = Array(this.size).fill().map(() => Array(this.size).fill(null)); |
| this.currentPlayer = 'black'; |
| this.lastMove = null; |
| this.passes = 0; |
| this.gameMode = 'pvp'; |
| this.score = { black: 0, white: 0 }; |
| this.capturedStones = { black: 0, white: 0 }; |
| this.stoneSound = document.getElementById('stoneSoundEffect'); |
| |
| this.initialize(); |
| } |
| |
| |
| |
| placeStone(row, col) { |
| if(this.board[row][col] === null) { |
| this.board[row][col] = this.currentPlayer; |
| this.renderStone(row, col); |
| this.captures(); |
| this.passes = 0; |
| this.currentPlayer = this.currentPlayer === 'black' ? 'white' : 'black'; |
| this.updateScore(); |
| |
| |
| this.stoneSound.currentTime = 0; |
| this.stoneSound.play(); |
| } |
| } |
| |
| |
| } |
| |
| const game = new GoGame(); |
| </script> |
| </body> |
| </html> |