Multiplayer Noughts & Crosses

Multiplayer Noughts & Crosses

This is the most challenging and fun project I’ve possibly ever worked on. Recently, I’ve been diving into the world of NodeJS to add to my back-end skills. I decided to check out Socket.IO to potentially create webpages that could communicate with the server in real-time (which enables all sorts of cool things from multiplayer games to real-time chat applications). I soon learnt about WebSockets, which is what Socket.IO uses, and decided to experiment with them next. I made a template for each demonstrating and applying my learning (Socket.IO one, WebSocket one).

After this, I wanted to really challenge myself to make a proper game from scratch using WebSockets. I happened to see this Repl, and almost immediately decided to make my own multiplayer Noughts and Crosses game. The result was my Noughts & Crosses Repl.

screenshot

While not perfect, I definitely feel satisfied with what I’ve created!

3 Likes

I wish I could play but there’s no one to play against lol

1 Like

Just saw this, I made a room if you want to try it out :slight_smile:

Edit: Hmm… seems something is wrong… lemme try and get it working…

Edit 2: Hmm… very weird, it works on my test account…

I think I may know why. When I ran the Repl, there wasn’t a login button. It just automatically logged me in.

1 Like

Huh, must be an issue with the authentication then…

Yeah, the login button is really weird. It appears for a second. Try joining my room now?

1 Like

I think the error is fixed, try now.

1 Like

Nice! BTW, the player who starts always goes with X.

1 Like

You mean the player who starts the room?

1 Like

The player who goes first. So it goes X, O, X, O, and so on. I’m assuming in your case it would be the player who starts the room.

1 Like

No, it’s decided based on recent matches, if one player was noughts last and the other was crosses last, then their roles should be reversed (the same if their roles last were switched). This check applies to the previous five matches, otherwise it is randomly decided.

1 Like

I searched it up and you’re right, I’ve just always played it with noughts starting… I’ll fix that up.

1 Like

Pretty cool lad! It’s cool that you made this from scratch, mainly because I can’t imagine what server communication scripting is like. Hopefully this gets popular, so there can actually be games going on.

1 Like

Thanks! The server scripting was pretty horrific because it was my first time creating a fully function multiplayer game. The code is pretty messy in the index.js file, however I am rather proud of the library I developed to interact with WebSockets which made the process somewhat easier. I hope so too :slight_smile:

This is so impressive @MattDESTROYER !!

1 Like