Multiplayer Tic-tac-toe [C2][Web2py(Python)][AJAX][Cross-domain]



Attached Files

The following files have been attached to this tutorial:



Download now 7.75 MB

Download now 4.42 KB


6,123 visits, 12,568 views



This tutorial hasn't been translated.


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.

Setting up web2py

When you download the file from the website, extract it to any location you seem fit.

Download my "web2py", you'll find two files there and

Go to [your extraction location]\web2py\applications\welcome\

And replace the files: in the models folder, in the controllers folder.

Launching web2py

Back in the web2py/ directory, you can make a shortcut of web2py.exe to your desktop:


You'll see this when you launch it:


Keep everything as it is, just type in a password, it doesn't have to be strong as you're on localhost "".

Now if you've replaced the files in the folders mentioned before, everything is actually set up at this point.

However you can access and edit the files in the admin interface:


Enter your password here:


Select to edit the Welcome application:


And here are the files:


Now the game

You'll see all the events and variables in the .capx file, I tried to comment on everything, so it could be understood as easily as possible.

The game consists of 18 global variables and 92 events. Could possibly be optimized to work with less, but that's not the goal of this tutorial.

We have 2 space ships, 9 rocks, a field to enter your nickname and some other text fields.

When you enter the nickname and press the "Find an opponent" it sends a request with your nickname to the web2py website, where the database checks if there's an active room with a free slot and you join that one. If there are no rooms that have a free slot, you're just assigned a new room id and your personal player id for identification. Then you wait for another player to connect.

When both players are connected, one textfield displays which player has the first move and another textfield shows the active event group, if it's GP1, it's your turn, if GP2, your waiting for the other player to make his move.

If you manage to connect 3 tic/tacs into a line, the game is over, your enemy's tacs are destroyed and your plane launches an attack destroying him. The game restarts in 5 sec after.

If there's a draw, both player ships destroy each other.


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