Skip to content
Snippets Groups Projects
Commit 6ae230b8 authored by Ulysse Durand's avatar Ulysse Durand
Browse files

kind of works:

parent 5f454e23
No related branches found
No related tags found
Loading
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
// Initialize game board // Initialize game board
function drawBoard(board) { function drawBoard(board) {
console.log(board);
// Draw Connect4 grid based on board state // Draw Connect4 grid based on board state
ctx.clearRect(0, 0, canvas.width, canvas.height); ctx.clearRect(0, 0, canvas.width, canvas.height);
for (let row = 0; row < ROWS; row++) { for (let row = 0; row < ROWS; row++) {
...@@ -59,7 +60,6 @@ ...@@ -59,7 +60,6 @@
} }
canvas.addEventListener('click', (e) => { canvas.addEventListener('click', (e) => {
if (winner !== null) return;
const rect = canvas.getBoundingClientRect(); const rect = canvas.getBoundingClientRect();
const x = e.clientX - rect.left; const x = e.clientX - rect.left;
const col = Math.floor(x / CELL_SIZE); const col = Math.floor(x / CELL_SIZE);
......
...@@ -54,6 +54,7 @@ io.on('connection', (socket) => { ...@@ -54,6 +54,7 @@ io.on('connection', (socket) => {
let startGame = (room, roomId) => { let startGame = (room, roomId) => {
console.log("Two players on room " + roomId + ", game starting."); console.log("Two players on room " + roomId + ", game starting.");
console.log(room);
io.to(roomId).emit('startGame', { io.to(roomId).emit('startGame', {
board: room.gameState, board: room.gameState,
currentPlayer: room.currentPlayer currentPlayer: room.currentPlayer
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment