commit 5425c6c20bf05a99ad67adb981d70c08d3f6aedc Author: Omar Date: Sat May 16 20:34:55 2020 +1000 Initial commit diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..6f8ef7d Binary files /dev/null and b/.DS_Store differ diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..dfe0770 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..cddf784 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Omar + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.markdown b/README.markdown new file mode 100644 index 0000000..73a00f8 --- /dev/null +++ b/README.markdown @@ -0,0 +1,5 @@ +# Dice + +A Pen created on CodePen.io. Original URL: [https://codepen.io/thecoderpenguin/pen/BaNVbLB](https://codepen.io/thecoderpenguin/pen/BaNVbLB). + + diff --git a/dist/index.html b/dist/index.html new file mode 100644 index 0000000..ffb2442 --- /dev/null +++ b/dist/index.html @@ -0,0 +1,22 @@ + + + + + CodePen - Dice + + + + + + +

Invention Game

+ + +
Roll That Dice
+ + + + + + + diff --git a/dist/script.js b/dist/script.js new file mode 100644 index 0000000..59a48df --- /dev/null +++ b/dist/script.js @@ -0,0 +1,139 @@ +const diceFaces = [ + "https://bit.ly/dice-unknown", + //MATERIAL - RED 1 + //Plastic + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616437/Material-100_x100-04_dznrm4.png", + //Edible + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616437/Material-100_x100-05_nze09o.png", + //Organic + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616437/Material-100_x100-06_lbz6ui.png", + //Paper + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616437/Material-100_x100-01_nxuwlk.png", + //Metal + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616436/Material-100_x100-02_tpybpi.png", + //Wood + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616436/Material-100_x100-03_aom9pj.png", + + //MOTIVE POWER - YELLOW 2 + //Electric + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616450/Motive_Power-100_x_100-04_ebwkeq.png", + //Manual + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616449/Motive_Power-100_x_100-02_oayuxs.png", + //Solar + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616449/Motive_Power-100_x_100-06_eauc07.png", + //Wind + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616449/Motive_Power-100_x_100-01_acbqgj.png", + //Water + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616449/Motive_Power-100_x_100-03_bwq3qy.png", + //Clockwork + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616449/Motive_Power-100_x_100-05_zwchd7.png", + + //SCALE - GREEN 3 + //Giant + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616384/Scale-100_x_100-06_iwbwvn.png", + //Pocket + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616383/Scale-100_x_100-02_kgtog5.png", + //Mini + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616383/Scale-100_x_100-04_jnqfws.png", + //Wearable + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616383/Scale-100_x_100-03_rdkcdn.png", + //Inhabitable + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616383/Scale-100_x_100-05_mi4kby.png", + //Portable + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616382/Scale-100_x_100-01_xwofbe.png", + + //DEVICE - BLUE 4 + //Art + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616396/Device-100_x_100-01_gp2scy.png", + //Vehicle + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616397/Device-100_x_100-06_tpee5i.png", + //Tool + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616397/Device-100_x_100-02_i1hlyf.png", + //Game + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616396/Device-100_x_100-03_qre686.png", + //Computer + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616396/Device-100_x_100-05_jfrffx.png", + //Robot + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616396/Device-100_x_100-04_kiyqbx.png", + + //CONSUMER - ORANGE 5 + //Personal + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616410/Consumer-_100_x_100-04_qtx1mp.png", + //Home + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616410/Consumer-_100_x_100-03_iq0dy3.png", + //Public + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616409/Consumer-_100_x_100-02_nm1poh.png", + //Family + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616409/Consumer-_100_x_100-01_po2icu.png", + //Office + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616409/Consumer-_100_x_100-05_f0exbj.png", + //Industrial + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616409/Consumer-_100_x_100-06_lwp6fp.png", + + //ACTION - PINK 6 + //Random + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616365/Action-_100_x_100-03_c3k2uh.png", + //Flying + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616365/Action-_100_x_100-02_waec4l.png", + //Stealth + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616365/Action-_100_x_100-05_uqaosl.png", + //Underwater + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616365/Action-_100_x_100-01_nxnewa.png", + //Self-Build + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616365/Action-_100_x_100-04_wzrwdg.png", + //Disposable + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616365/Action-_100_x_100-06_gqz9ys.png" +]; + +for (const element of diceFaces) { +} + +// Cleans up code later +var image = document.getElementById("dice"); +var image2 = document.getElementById("dice2"); +var image3 = document.getElementById("dice3"); +var image4 = document.getElementById("dice4"); +var image5 = document.getElementById("dice5"); +var image6 = document.getElementById("dice6"); + +var audio = document.getElementById("audio"); + +// Gets a random integer, min & max inclusive +function getRandomInt(min, max) { + min = Math.ceil(min); + max = Math.floor(max); + return Math.floor(Math.random() * (max - min + 1)) + min; +} + +function rollThatDice() { + audio.currentTime = 0; + image.style.animation = "spindice 0.25s"; + image2.style.animation = "spindice 0.25s"; + image3.style.animation = "spindice 0.25s"; + image4.style.animation = "spindice 0.25s"; + image5.style.animation = "spindice 0.25s"; + image6.style.animation = "spindice 0.25s"; + + setTimeout(function () { + image.setAttribute("src", diceFaces[getRandomInt(1, 6)]); + image2.setAttribute("src", diceFaces[getRandomInt(7, 12)]); + image3.setAttribute("src", diceFaces[getRandomInt(13, 18)]); + image4.setAttribute("src", diceFaces[getRandomInt(19, 24)]); + image5.setAttribute("src", diceFaces[getRandomInt(25, 30)]); + image6.setAttribute("src", diceFaces[getRandomInt(31, 36)]); + }, 125); + + setTimeout(function () { + image.style.animation = "none"; + image2.style.animation = "none"; + image3.style.animation = "none"; + image4.style.animation = "none"; + image5.style.animation = "none"; + image6.style.animation = "none"; + }, 250); + audio.play(); +} + +document.addEventListener("DOMContentLoaded", function (event) { + rollThatDice(); +}); \ No newline at end of file diff --git a/dist/style.css b/dist/style.css new file mode 100644 index 0000000..f9f98f1 --- /dev/null +++ b/dist/style.css @@ -0,0 +1,78 @@ + @import url("https://fonts.googleapis.com/css?family=Indie+Flower"); +body { + font-family: "Indie Flower", sans-serif; + background-color: #303030; + color: #fff; + display: -webkit-box; + display: flex; + -webkit-box-pack: center; + justify-content: center; + -webkit-box-align: center; + align-items: center; + -webkit-box-orient: horizontal; + -webkit-box-direction: normal; + flex-direction: row; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +h1 { + font-size: 45px; +} + +@-webkit-keyframes spindice { + 0% { + -webkit-transform: rotate(0deg); + transform: rotate(0deg); + -webkit-filter: blur(5px); + filter: blur(5px); + } + 100% { + -webkit-transform: rotate(360deg); + transform: rotate(360deg); + -webkit-filter: blur(5px); + filter: blur(5px); + } +} + +@keyframes spindice { + 0% { + -webkit-transform: rotate(0deg); + transform: rotate(0deg); + -webkit-filter: blur(5px); + filter: blur(5px); + } + 100% { + -webkit-transform: rotate(360deg); + transform: rotate(360deg); + -webkit-filter: blur(5px); + filter: blur(5px); + } +} + + +div { + font-size: 16px; + color: #fff; + background-color: #01944C; + height: auto; + border: none; + padding: 1px 80px; + border-radius: 50px; + cursor: pointer; + -webkit-transition: all 0.5s; + transition: all 0.5s; +=} +div:hover { + background-color: #fff; + color: #303030; +} + +img { + width: 80px; + padding: 10px; + -webkit-animation: none; + animation: none; + } \ No newline at end of file diff --git a/license.txt b/license.txt new file mode 100644 index 0000000..35b0817 --- /dev/null +++ b/license.txt @@ -0,0 +1,9 @@ +Copyright (c) 2020 by omar (https://codepen.io/thecoderpenguin/pen/BaNVbLB) +Fork of an original work Dice (https://codepen.io/charliebritton/pen/RVyBLr + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/src/index.pug b/src/index.pug new file mode 100644 index 0000000..a505d9e --- /dev/null +++ b/src/index.pug @@ -0,0 +1,15 @@ +h1.header Invention Game + +// Shows a question mark whilst loading +img(src="https://bit.ly/dice-unknown")#dice +img(src="https://bit.ly/dice-unknown")#dice2 +img(src="https://bit.ly/dice-unknown")#dice3 +img(src="https://bit.ly/dice-unknown")#dice4 +img(src="https://bit.ly/dice-unknown")#dice5 +img(src="https://bit.ly/dice-unknown")#dice6 + +// When you click the div, it executes rollThatDice() +div(onclick="rollThatDice()") Roll That Dice + +// A link to the roll sound you hear +audio(src="https://bit.ly/dice-sound")#audio \ No newline at end of file diff --git a/src/script.js b/src/script.js new file mode 100644 index 0000000..ef3e110 --- /dev/null +++ b/src/script.js @@ -0,0 +1,139 @@ +const diceFaces = [ + "https://bit.ly/dice-unknown", + //MATERIAL - RED 1 + //Plastic + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616437/Material-100_x100-04_dznrm4.png", + //Edible + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616437/Material-100_x100-05_nze09o.png", + //Organic + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616437/Material-100_x100-06_lbz6ui.png", + //Paper + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616437/Material-100_x100-01_nxuwlk.png", + //Metal + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616436/Material-100_x100-02_tpybpi.png", + //Wood + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616436/Material-100_x100-03_aom9pj.png", + + //MOTIVE POWER - YELLOW 2 + //Electric + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616450/Motive_Power-100_x_100-04_ebwkeq.png", + //Manual + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616449/Motive_Power-100_x_100-02_oayuxs.png", + //Solar + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616449/Motive_Power-100_x_100-06_eauc07.png", + //Wind + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616449/Motive_Power-100_x_100-01_acbqgj.png", + //Water + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616449/Motive_Power-100_x_100-03_bwq3qy.png", + //Clockwork + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616449/Motive_Power-100_x_100-05_zwchd7.png", + + //SCALE - GREEN 3 + //Giant + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616384/Scale-100_x_100-06_iwbwvn.png", + //Pocket + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616383/Scale-100_x_100-02_kgtog5.png", + //Mini + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616383/Scale-100_x_100-04_jnqfws.png", + //Wearable + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616383/Scale-100_x_100-03_rdkcdn.png", + //Inhabitable + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616383/Scale-100_x_100-05_mi4kby.png", + //Portable + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616382/Scale-100_x_100-01_xwofbe.png", + + //DEVICE - BLUE 4 + //Art + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616396/Device-100_x_100-01_gp2scy.png", + //Vehicle + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616397/Device-100_x_100-06_tpee5i.png", + //Tool + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616397/Device-100_x_100-02_i1hlyf.png", + //Game + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616396/Device-100_x_100-03_qre686.png", + //Computer + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616396/Device-100_x_100-05_jfrffx.png", + //Robot + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616396/Device-100_x_100-04_kiyqbx.png", + + //CONSUMER - ORANGE 5 + //Personal + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616410/Consumer-_100_x_100-04_qtx1mp.png", + //Home + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616410/Consumer-_100_x_100-03_iq0dy3.png", + //Public + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616409/Consumer-_100_x_100-02_nm1poh.png", + //Family + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616409/Consumer-_100_x_100-01_po2icu.png", + //Office + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616409/Consumer-_100_x_100-05_f0exbj.png", + //Industrial + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616409/Consumer-_100_x_100-06_lwp6fp.png", + + //ACTION - PINK 6 + //Random + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616365/Action-_100_x_100-03_c3k2uh.png", + //Flying + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616365/Action-_100_x_100-02_waec4l.png", + //Stealth + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616365/Action-_100_x_100-05_uqaosl.png", + //Underwater + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616365/Action-_100_x_100-01_nxnewa.png", + //Self-Build + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616365/Action-_100_x_100-04_wzrwdg.png", + //Disposable + "https://res.cloudinary.com/dmnr5acns/image/upload/v1589616365/Action-_100_x_100-06_gqz9ys.png" +]; + +for (const element of diceFaces) { +} + +// Cleans up code later +var image = document.getElementById("dice"); +var image2 = document.getElementById("dice2"); +var image3 = document.getElementById("dice3"); +var image4 = document.getElementById("dice4"); +var image5 = document.getElementById("dice5"); +var image6 = document.getElementById("dice6"); + +var audio = document.getElementById("audio"); + +// Gets a random integer, min & max inclusive +function getRandomInt(min, max) { + min = Math.ceil(min); + max = Math.floor(max); + return Math.floor(Math.random() * (max - min + 1)) + min; +} + +function rollThatDice() { + audio.currentTime = 0; + image.style.animation = "spindice 0.25s"; + image2.style.animation = "spindice 0.25s"; + image3.style.animation = "spindice 0.25s"; + image4.style.animation = "spindice 0.25s"; + image5.style.animation = "spindice 0.25s"; + image6.style.animation = "spindice 0.25s"; + + setTimeout(function () { + image.setAttribute("src", diceFaces[getRandomInt(1, 6)]); + image2.setAttribute("src", diceFaces[getRandomInt(7, 12)]); + image3.setAttribute("src", diceFaces[getRandomInt(13, 18)]); + image4.setAttribute("src", diceFaces[getRandomInt(19, 24)]); + image5.setAttribute("src", diceFaces[getRandomInt(25, 30)]); + image6.setAttribute("src", diceFaces[getRandomInt(31, 36)]); + }, 125); + + setTimeout(function () { + image.style.animation = "none"; + image2.style.animation = "none"; + image3.style.animation = "none"; + image4.style.animation = "none"; + image5.style.animation = "none"; + image6.style.animation = "none"; + }, 250); + audio.play(); +} + +document.addEventListener("DOMContentLoaded", function (event) { + rollThatDice(); +}); diff --git a/src/style.sass b/src/style.sass new file mode 100644 index 0000000..0b2c660 --- /dev/null +++ b/src/style.sass @@ -0,0 +1,43 @@ +@import url('https://fonts.googleapis.com/css?family=Indie+Flower') + +body + width: 100vw + height: 100vh + font-family: 'Indie Flower', sans-serif + background-color: #303030 + color: #fff + display: flex + justify-content: center + align-items: center + flex-direction: row + user-select: none + +h1 + font-size: 25vh + +@keyframes spindice + 0% + transform: rotate(0deg) + filter: blur(5px) + 100% + transform: rotate(360deg) + filter: blur(5px) + +img + width: 40vh + padding: 5vh + animation: none + +div + font-size: 10vh + color: #fff + background-color: #01944C + height: auto + border: none + padding: 5vh 10vh + border-radius: 50px + cursor: pointer + transition: all 0.5s + &:hover + background-color: #fff + color: #303030