Tic-Tac-Toe - Part 3 - Multiplayer, with a Lobby

Favourite 37 favourites
Tutorial written by blackhornetOriginally published on 5th, May 2014 - 2 revisions

eGame Event Sheet

There isn't much here. Since there isn't much interaction in Tic-Tac-Toe, the few user events just call functions on the eCommunications event sheet to send messages to the other player. TileHiliting and board-tile-presses are sent.


Communications are broken up into outgoing Commands, and incoming Messages.
CmdTileHilite() - this builds up a hilite message of the X, Y, and hilite value for a tile.
If the message isn't the same as the last one, we send the TileHilite message, store the message to compare against next time, and call HiliteTile() to hilite the tile on our side.
CmdMakeMove() - we send the message to the other player of the X, Y, and move(X or O), call MarkTheMove() to mark the tile on our side, and then check for a winner. If the game isn't flaged as over, call SwitchPlayer() to switch who's turn it is.
CmdRestart() - this just resets everything to start the game over. We flip who starts first, and send a Restart message to the other player with who moves first.
These match what we just covered, only when we are the "other" player.
"TileHilite" message - decode the parameters, and call HiliteTile().
"MakeMove" - decode the parameters and MarkTheMove() and check for game over. Switch players as appropriate.
"Restart" - set the first move ID and go to the Game layout.

Share and Copy this Tutorial

You are free to copy, distribute, transmit and adapt this work with correct attribution. Click for more info.


Wsoukkachang 1,433 rep

Nice! Very useful!

Monday, May 05, 2014 at 4:19:32 AM
qu0y 3,151 rep

So considerate, thanks for being always so helpful!

Monday, May 05, 2014 at 2:29:55 PM
Scofano 2,765 rep

Thanks for sharing.

Monday, May 05, 2014 at 5:50:29 PM
Tedg 9,893 rep

Thanks for share this !)

Monday, May 05, 2014 at 6:53:22 PM
DUTOIT 12.8k rep

Oh, Wow, going to savour this one :) Looks fantastic.

Monday, May 05, 2014 at 7:54:54 PM
AbelaNET 14.9k rep

Thanks for sharing

Tuesday, May 06, 2014 at 8:22:39 AM
beardedeagle 2,020 rep

Multiplayer is the next thing I have to implement into my game and this will be very helpful to get me there. Thank you!

Monday, July 07, 2014 at 7:08:18 PM

Leave a comment

Everyone is welcome to leave their thoughts! Register a new account or login.