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

3

Index

Attached Files

The following files have been attached to this tutorial:

.capx

tttmp-client-130.capx

Download now 908.03 KB
.capx

tttmp-lobby-100.capx

Download now 175.5 KB

Stats

12,215 visits, 25,410 views

Tools

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 5 May, 2014. Last updated 19 Feb, 2019

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.

eCommunications

Communications are broken up into outgoing Commands, and incoming Messages.

Commands

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.

Messages

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.

  • 0 Comments

Want to leave a comment? Login or Register an account!