From a6de458d3250704b3040ce0e2dadd1d60144d195 Mon Sep 17 00:00:00 2001 From: Michael Ross Date: Mon, 17 Jan 2022 09:18:57 -0800 Subject: [PATCH 1/3] Add Script tags --- Challenge 24/index.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Challenge 24/index.html b/Challenge 24/index.html index 80ef3d0..f336800 100644 --- a/Challenge 24/index.html +++ b/Challenge 24/index.html @@ -4,6 +4,8 @@ - Hi + \ No newline at end of file From 2bb6797a4984ada048000f032eae804722eb872c Mon Sep 17 00:00:00 2001 From: Michael Ross Date: Mon, 17 Jan 2022 10:30:30 -0800 Subject: [PATCH 2/3] Add Game Over variable --- TicTacToe/js/tictactoe.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/TicTacToe/js/tictactoe.js b/TicTacToe/js/tictactoe.js index 825e498..020e7b9 100644 --- a/TicTacToe/js/tictactoe.js +++ b/TicTacToe/js/tictactoe.js @@ -2,7 +2,8 @@ let activePlayer = 'X'; //This array stores an array of moves. We use this to determine win conditions. let selectedSquares = []; - +//Initialize gameover state as false +let gameover = Boolean(false); //This function is for placing an x or o in a square. function placeXOrO(squareNumber) { //This condition ensures a square hasn't been selected already. @@ -49,6 +50,12 @@ function placeXOrO(squareNumber) { //This function results in a random square being selected. function computersTurn() { + //Check if in Win Condition + if (gameover) { + console.log("Game Over"); + console.log(gameover); + return; + }; //This boolean is needed for our while loop. let success = false; //This varialbe stores a random number 0-8 @@ -62,6 +69,9 @@ function placeXOrO(squareNumber) { if (placeXOrO(pickASquare)){ //This line calls the function. placeXOrO(pickASquare); + //log our variables + console.log(pickASquare); + console.log(gameover); //This changes our boolean and ends the loop. success = true; }; @@ -108,6 +118,9 @@ function checkWinConditions() { else if (selectedSquares.length >= 9) { //This function plays the tie game sound. audio('./media/tie.mp3'); + + //set game state as gameover true + gameover = Boolean(true); //This function sets a .3 second timer before resetGame is called. setTimeout(function () { resetGame(); }, 1000); } @@ -141,6 +154,10 @@ function audio(audioURL) { } //This function utilizes html canvas to draw win lines. function drawWinLine(coordX1, coordY1, coordX2, coordY2) { + //Log Game over + console.log("Game Over"); + //Set Game Over State + gameover = Boolean(true); //This line access our html canvas element. const canvas = document.getElementById('win-lines'); //This line gives us access to methods and properties to use on canvas. @@ -204,6 +221,8 @@ function drawWinLine(coordX1, coordY1, coordX2, coordY2) { } //This line disallows clicking while the win sound is playing disableClick(); + //Set Game over state + gameover = Boolean(true); //This line plays the win sounds. audio('./media/winGame.mp3'); //This line calls our main animation loop. @@ -223,4 +242,7 @@ function resetGame() { } //This resets our array so it is empty and we can start over. selectedSquares = []; + //Reset game state + gameover = Boolean(false); + } \ No newline at end of file From 3e52860c8ac465e0e4898670313eb1f1a500ac6a Mon Sep 17 00:00:00 2001 From: Michael Ross Date: Tue, 18 Jan 2022 09:49:34 -0800 Subject: [PATCH 3/3] fix reactdom --- React_Projects/React_1.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/React_Projects/React_1.html b/React_Projects/React_1.html index e3af4e7..3599759 100644 --- a/React_Projects/React_1.html +++ b/React_Projects/React_1.html @@ -21,9 +21,9 @@ var counter_Factory = React.createFactory(Counter); var start_Counting = new Date().getTime(); - setInterval(Function() { + setInterval(function() { ReactDOM.render( - counter_Factory({time_Passed: new Date().getTime() = start_Counting}), + counter_Factory({time_Passed: new Date().getTime() - start_Counting}), document.getElementById('My_React_Code') ); }, 50);