Summary
In this chapter, you have created a fully functional pvp game based on tic-tac-toe mechanics. At the moment, the game is playable and handles all the basics of the game; however, there is a lot of improvement that we can implement in our code.
With the information given to you in this chapter, try to write your own code that improves the game that you just created. There are plenty of choices and it depends on you. Here's some suggestions of what you can do with the elements that you have:
- Improve the CheckIfWin macro. This macro can be done with only nine calls to the isOwner macro.
- Handle the draw. Yes, it could happen that no one wins the match as no other moves are possible. Implement this on the CheckIfWin macro.
Tip
Use a variable to store the number of blocks clicked on the grid. If a match reaches the max number of blocks, it means that no other moves are possible.
- Wait for a player input before cleaning the grid. A player will like to see how he loses or wins the match.
Tip...