diff --git a/.gitignore b/.gitignore index 88d86a4..2c5a5b7 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ docs/img/week4/instagramAPI.fw.png 02-servi/_serviScratch/* 10-server-side/06-servi-db/people.db sandbox/* +week3/07game_example/images/fw/* diff --git a/week3/07game_example/css/style.css b/week3/07game_example/css/style.css new file mode 100644 index 0000000..f17d869 --- /dev/null +++ b/week3/07game_example/css/style.css @@ -0,0 +1,20 @@ +#gameboard{ + width: 1150px; + margin: auto; +} +.gamecard{ + border:1px solid #333; + background-color: pink; + width:250px; + height:250px; + margin: 10px; + float:left; +} +/* all images inside gamecard classes */ +.gamecard img{ + display:none; +} +h1{ + text-align: center; + +} \ No newline at end of file diff --git a/week3/07game_example/images/boat.png b/week3/07game_example/images/boat.png new file mode 100644 index 0000000..23d52b8 Binary files /dev/null and b/week3/07game_example/images/boat.png differ diff --git a/week3/07game_example/images/cat.png b/week3/07game_example/images/cat.png new file mode 100644 index 0000000..9b7d84a Binary files /dev/null and b/week3/07game_example/images/cat.png differ diff --git a/week3/07game_example/images/drink.png b/week3/07game_example/images/drink.png new file mode 100644 index 0000000..4ccb9a8 Binary files /dev/null and b/week3/07game_example/images/drink.png differ diff --git a/week3/07game_example/images/shoes.png b/week3/07game_example/images/shoes.png new file mode 100644 index 0000000..ceaca79 Binary files /dev/null and b/week3/07game_example/images/shoes.png differ diff --git a/week3/07game_example/index.html b/week3/07game_example/index.html new file mode 100644 index 0000000..5cf8fc4 --- /dev/null +++ b/week3/07game_example/index.html @@ -0,0 +1,17 @@ + + + + Matching Game + + + + + +

Turn over 2 cards at a time to find matches

+
+ +
+ + + + \ No newline at end of file diff --git a/week3/07game_example/js/game.js b/week3/07game_example/js/game.js new file mode 100644 index 0000000..9481368 --- /dev/null +++ b/week3/07game_example/js/game.js @@ -0,0 +1,136 @@ +// get the main game board div +var board = document.getElementById("gameboard"); + +var numCards = 8; + +// list the images to be used. (each will be used twice) +var images = [ + "cat.png", + "shoes.png", + "boat.png", + "drink.png" + ]; +// make a new array that has 2 of each image +var double_images = images.concat(images); +// fyi, re: the concat function: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat + +// shuffle the order (see custom function below) +shuffle(double_images); +//console.log(double_images); // uncomment to see what's in the image array + +// array to track which cards are turned over +var faceUpCards = []; +// track the number of successful matches +var numMatches = 0; + + +// Create the cards +for (var i=0; i