Initial commit
This commit is contained in:
commit
5425c6c20b
11 changed files with 473 additions and 0 deletions
BIN
.DS_Store
vendored
Normal file
BIN
.DS_Store
vendored
Normal file
Binary file not shown.
2
.gitattributes
vendored
Normal file
2
.gitattributes
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
# Auto detect text files and perform LF normalization
|
||||
* text=auto
|
||||
21
LICENSE
Normal file
21
LICENSE
Normal file
|
|
@ -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.
|
||||
5
README.markdown
Normal file
5
README.markdown
Normal file
|
|
@ -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).
|
||||
|
||||
|
||||
22
dist/index.html
vendored
Normal file
22
dist/index.html
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en" >
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>CodePen - Dice</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css">
|
||||
<link rel="stylesheet" href="./style.css">
|
||||
|
||||
</head>
|
||||
<body style="height: 214px; width: 900px; box-sizing: border-box; display: flex; align-items: center; justify-content: right; margin: 1em 0; padding: 1em;" data-pen-title="Dice">
|
||||
<!-- partial:index.partial.html -->
|
||||
<h1 class="header">Invention Game</h1>
|
||||
<!-- Shows a question mark whilst loading--><img src="https://bit.ly/dice-unknown" id="dice"/><img src="https://bit.ly/dice-unknown" id="dice2"/><img src="https://bit.ly/dice-unknown" id="dice3"/><img src="https://bit.ly/dice-unknown" id="dice4"/><img src="https://bit.ly/dice-unknown" id="dice5"/><img src="https://bit.ly/dice-unknown" id="dice6"/>
|
||||
<!-- When you click the div, it executes rollThatDice()-->
|
||||
<div onclick="rollThatDice()">Roll That Dice</div>
|
||||
<!-- A link to the roll sound you hear-->
|
||||
<audio src="https://bit.ly/dice-sound" id="audio"></audio>
|
||||
<!-- partial -->
|
||||
<script src="./script.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
139
dist/script.js
vendored
Normal file
139
dist/script.js
vendored
Normal file
|
|
@ -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();
|
||||
});
|
||||
78
dist/style.css
vendored
Normal file
78
dist/style.css
vendored
Normal file
|
|
@ -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;
|
||||
}
|
||||
9
license.txt
Normal file
9
license.txt
Normal file
|
|
@ -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.
|
||||
|
||||
15
src/index.pug
Normal file
15
src/index.pug
Normal file
|
|
@ -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
|
||||
139
src/script.js
Normal file
139
src/script.js
Normal file
|
|
@ -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();
|
||||
});
|
||||
43
src/style.sass
Normal file
43
src/style.sass
Normal file
|
|
@ -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
|
||||
Loading…
Add table
Reference in a new issue