This project allows users to play tic tac toe with a friend sitting nearby. The program will automatically switch turns between plays, and asses for a win or a draw. Once the game has ended, after a few moments the board will refresh and it will record who one that game.
- JavaScript
- Html
- CSS
- From the tic-tac-toe-SOLO repo click the code button and copy the SSH link.
- Open terminal by pressing command + space bar, and search for terminal
- Inside of you terminal type "git clone" and then paste the ssh link should look like "git clone [email protected]:Ekaiman/tic-tac-toe-SOLO.git"
- In your terminal type "cd tic-tac-toe-SOLO"
- Then type "open index.html"
- The browser should then deploy
- On opening the browser, it is player ones turn.
- Click on a square, or use tab and enter to place your token.
- Then its player twos turn.
- Repeat until there is a winner.
- The board will automatically refresh and switch which player begins the next round.
-
This project consists of 5 different files - index.html, css.styles, main.js, game.js, player.js.
-
game.js and player.js are both classes that hold the data models.
-
game.js holds all neccesary information for the games logic including :Game board data, Win conditions, If the game is still active, Which players turn, Who starts
-
The game board data gameBoardSquares is an object. Each key in the project directly corresponds to a box in the HTML and has the same naming as its corresponding boxs' id.
-
The game starts all of the properties start with a value of 0.
-
As the players pick a square, the number changes to a 1 or a 2 depending on whos placed in that sqaure.
-
Win conditions is an array of arrays holding the box property names that make a win.
-
The win conditions array is iterated through in the checkForWin method. This method checks to see if those three properties have the same number, if so, that is a win.
-
player.js is a class that hold the players id and their token
-
a new instance of player is created in the game class where and individual id and token are given to each player
-
main.js hold all event listeners, function required to mainpulate the DOM, a new instance of the game class, and the function that start the game
- Create an option to play against a computer.
- Allow users to pick their token from a drop down menu.
- Add music to browser.
- Seperating the data model and the DOM was a challenge at first, but got easier to understand with more time.
- Using bracket notation for variables and creating dynamic functions was challenging, and a win at the same time.
- Completeing the project was a win!
- Learning how to effectively use the console to troubleshoot isues and manually run the game was a huge win! ๐ฅณ