Chapter 6. Multiplayer Game Example: Tic-tac-toe

In this chapter, we will walk through the tic-tac-toe sample that is part of the freely downloadable Pulse SDK package. We will focus solely on this sample, exploring every class in detail that is involved in building this simple multiplayer game. The walk-through starts with schema design for the game, then proceeds to the subclassing of the PulseUI screen classes as required for this game, and finally focuses on the game screen and gameplay implementation.

Tic-tac-toe, for those who are not familiar with it, is a turn-based game where each player draws a circle or a cross in one of the available nine spots. If the player is able to place three of their symbols in a straight line, either in a straight row, column, or diagonally, then the player wins.

If neither of the players is able to make a straight line and there is no more room to place the symbol, then the play is considered a draw—no one wins. If a player wins, he or she will be a awarded a score of 1. The game round ends if one of the players wins or the game is a tie. The board is cleared and a new round begins.

In this chapter, we will cover the following with regards to the multiplayer tic-tac-toe game:

  • The Schema design
  • Subclassing from PulseUI
  • Player turn management
  • Implementing the game graphics
  • Determining a win or a loss

The following is a screenshot from the tic-tac-toe game showing two player screens side-by-side:

Multiplayer Game Example: Tic-tac-toe

Running the game from sample directory

Start the Pulse server from the installed directory. Start the game from the sample directory. Please note that with the free server version you can only run one game at any given time. If you want to try a different sample, you first need to close all the game client instances of the other game and restart the server. Complete details on downloading, installing, and running the samples can be found in Chapter 1.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.227.24.60