The first thing to think about is how best way to share the game states among all the players in the room.
Model the game
For the tic tac toe game you would need to send the player action to the other player, meaning, the client has to send up the x and y position.
The first thing to do then is to create a simple xml file that defines the game state you need during game play.
There are two steps:
1. Create the XML file.
2. Generate the source using the PulseCodeGen located in the bin of installed folder.
In the above schema file, we would like to communicate to other players of their actions, what is needed for this game is quite simple. The player choosing the spot (row and column) and the value, meaning an X or an O, the put value is determined at the start of the game depending on who actually created the game room (the game host).
After having designed game states are needed for the game, we need to run the above xml file through the PulseCodeGen tool. Following is a listing of batch file that will do exactly that.\
IF EXIST .\src\tictactoe\gsrc\client del .\src\tictactoe\gsrc\client\*.as
CALL "%GAMANTRA%"\bin\PulseCodeGen.bat .\tictactoeSchema.xml tictactoe.gsrc .\src\tictactoe\gsrc
IF NOT %ERRORLEVEL% == 0 GOTO ERROR
The batch file convenient so if you changed the schema, the regeneration of source files is a quick process.
|» Level Intermediate|
Rating: 6.22 Votes: 27
|Prashanth Hirematada is the founder & Chief Architect of Gamantra, a game technology company.|
|Download the files used in this tutorial.|
|Download (0 kb)|
|More help? Search our boards for quick answers!|