Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add - Dice Roll Game From HTML, CSS, JavaScript #69

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Dice Roll/assets/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Dice Roll/assets/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Dice Roll/assets/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Dice Roll/assets/4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Dice Roll/assets/5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Dice Roll/assets/6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Dice Roll/assets/dice-roll.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Dice Roll/assets/dice.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Dice Roll/font/sans.ttf
Binary file not shown.
20 changes: 20 additions & 0 deletions Dice Roll/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="assets/dice.png" type="image/x-icon">
<link rel="stylesheet" href="style.css">
<title>Dice Roller</title>
</head>
<body>
<div class="section">
<h2>Dice Roll</h2>
<img src="assets/1.png" alt="" id="img">
<br>
<div id="btn" onclick="anim();" >Shuffle</div>
</div>
<script src="script.js"></script>
</body>
</html>
11 changes: 11 additions & 0 deletions Dice Roll/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function shuffle(){
const img = document.getElementById("img");
let random = Math.floor(Math.random() * 6) + 1;
img.setAttribute("src", `assets/${random}.png`);
}

function anim(){
setTimeout(shuffle, 500);
const img = document.getElementById("img");
img.setAttribute("src", "assets/dice-roll.gif");
}
70 changes: 70 additions & 0 deletions Dice Roll/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
* {
margin: 0;
padding: 0;

font-family: "sans";
user-select: none;
}

@font-face {
font-family: "sans";
src: url(font/sans.ttf);
}

h2 {
position: absolute;
top: 0;
padding-top: 140px;
color: white;
font-size: 2rem;
text-align: center;
}

.section {
width: 100%;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
background: #6d6a8f;
}

#img {
width: 150px;
height: 150px;
}

#btn {
position: absolute;
cursor: pointer;
color: #fff;
background: #333;
font-size: 24px;
padding: 15px;
border-radius: 8px;
bottom: 0;
margin: 150px ;
}

#btn:active {
background: #1e8e3e;
}

footer {
text-align: center;
color: white;
font-size: 1rem;
position: absolute;
left: 0;
right: 0;
bottom: 0;
margin-bottom: 0;
padding: 5px;
line-height: 3vh;
}

footer a:visited {
color: inherit;
}