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

CODEAVATARS - DICE GAME SUBMISSION #21

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
36 changes: 36 additions & 0 deletions CODE AVATARS/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Project Name - Dice Game
# Issue No - #20
# Project Description
Build a dice-rolling game. A group of people initially (invite only) will join in, guess a number from the range
[1, 6], and then put a bet upon their guess. The one who guesses the output correctly is treated as the
winner(s). Then the entire pool of bets automatically gets distributed across these winner(s). The main
challenge here is to generate a perfectly random number in the given range (of course on-chain) so as to
avoid any misleads. Once this is achieved, a complete section of games can be further built upon this
random module.

# Problem trying to Solve
The Problem is to develop an interactive dice game . And to provide engaging audio experience while pressing the key buttons Audio API is used for the functionality

Randomized set of combinations of dice is achieved through random() function of js which will be the backbone for the project
interactive audio api is used on clicking game button to generate sound and responsive user interface is used for buttons

# Tech Stack
[![skills](https://skillicons.dev/icons?i=html,css,js&perline=5)](https://skillicons.dev)

# Project Photo

<img width="941" alt="image" src="https://github.com/TRIOYJK/DiceGame/assets/82363361/a4f1b54a-2515-4780-a8ad-caac68386700">

# To view the website

https://trioyjk.github.io/DiceGame/

# PPT link

[Click here to view ](https://github.com/Yasaswini25/DiceGame/blob/312b3e90c711b84c56e6df1a86a7a8fea6df2808/wepik-rolling-the-dice-exploring-the-exciting-world-of-web-development-dice-game-2023082315141268dz.pdf)

# Contributors

[![](https://github.com/Yasaswini25.png?size=50)](https://github.com/Yasaswini25) [![](https://github.com/JayanthReddyG.png?size=50)](https://github.com/JayanthReddyG) [![](https://github.com/komalreddy3.png?size=50)](https://github.com/komalreddy3)


Binary file added CODE AVATARS/bg.jpg
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 CODE AVATARS/d1.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 CODE AVATARS/d2.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 CODE AVATARS/d3.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 CODE AVATARS/d4.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 CODE AVATARS/d5.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 CODE AVATARS/d6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions CODE AVATARS/del
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Binary file added CODE AVATARS/diceroll.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 45 additions & 0 deletions CODE AVATARS/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<!-- CONTRIBUTORS

JNANA YASASWINI

G JAYANTH REDDY

KOMAL REDDY K -->

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>Dice Game</title>
</head>
<body onload="begin()">

<div class="container">
<h1 >Let's Begin</h1>
<div class="wrapper">
<div class="dice">
<p class="Player1">Player1</p>
<img src="./d6.png" alt="dice 6" class="img1" style="width: 100px;">
</div>
<div class="dice">
<p class="Player2">Player2</p>
<img src="./d6.png" alt="dice 6" class="img2" style="width: 100px;">
</div>
</div>
</div>
<div class="wrapper">
<div class="container-bottom">
<button type="button" class="btn" onclick="rollthedice()">Roll It</button>
</div>
<div class="container-bottom">
<button type="button" class="btn" onclick="changenames()"> Change Names</button>
</div>
</div>


<script src="script.js"></script>
</body>
</html>

Binary file added CODE AVATARS/rolldice.mp3
Binary file not shown.
61 changes: 61 additions & 0 deletions CODE AVATARS/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// CONTRIBUTORS

// JNANA YASASWINI

// G JAYANTH REDDY

// KOMAL REDDY K


let player1 = "Player1";
let player2 = "Player2";
function changenames() {
player1 = prompt("change player1 name");
player2 = prompt("change player2 name");
if (player1.length < 1 || player2.length < 1) {
alert("please enter a valid name");
return;
}
document.querySelector("p.Player1").innerHTML = player1;
document.querySelector("p.Player2").innerHTML = player2;
}
function begin() {
let r = document.querySelector("h1");
let utterance = new SpeechSynthesisUtterance(`${r.innerText}`);
speechSynthesis.speak(utterance);
}
function rollthedice() {
let diceNum1 = document.querySelector(".img1");
let diceNum2 = document.querySelector(".img2");

diceNum1.setAttribute("src", "./diceroll.gif");
diceNum2.setAttribute("src", "./diceroll.gif");
audio = new Audio("./rolldice.mp3");
audio.play();

let result = document.querySelector("h1");
setTimeout(() => {
let randomNumber1 = Math.floor(Math.random() * 6) + 1;
let randomNumber2 = Math.floor(Math.random() * 6) + 1;

diceNum1.setAttribute("src", "./d" + randomNumber1 + ".png");
diceNum2.setAttribute("src", "./d" + randomNumber2 + ".png");

if (randomNumber1 == randomNumber2) {
result.innerHTML = "TIE";
} else if (randomNumber1 < randomNumber2) {
result.innerHTML = player2 + " Won";
} else {
result.innerHTML = player1 + " Won";
}
let speakout = new SpeechSynthesisUtterance(`${result.innerText}`);
speechSynthesis.speak(speakout);
audio = new Audio("./success.mp3");
audio.play();
let speakout1 = new SpeechSynthesisUtterance(`Lets Begin`);
speechSynthesis.speak(speakout1);
setTimeout(() => {
result.innerHTML = "Let's Begin";
}, 1000);
}, 2500);
}
58 changes: 58 additions & 0 deletions CODE AVATARS/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/* CONTRIBUTORS

JNANA YASASWINI

G JAYANTH REDDY

KOMAL REDDY K */


*{
margin: 0;
padding : 0;
font-family: 'Times New Roman', Times, serif;
box-sizing:border-box;
}
body{
background-image: url("./bg.jpg");
width: 100%;
height: 100%;
padding: 5rem;
align-items: center;
padding-bottom: 200px;
justify-content: center;
background-repeat: no-repeat;
background-position: right;
background-size:800px 840px;
/* background-color: rgba(219, 246, 228, 0.936);*/

}
h1{
font-size: 32px;
text-align: center;
font-weight: 1000;
}
.dice,.container-bottom{
width: 250px;
padding: 30px;

border-radius: 5px;
}
.wrapper{
display: flex;
}
.btn{
background-color: #0f3b8df2;;
color: rgb(255, 250, 250);
border-radius: 5px;
font-size: 19px;
padding: 10px 30px 10px 30px;
cursor: pointer;
}
.img1,.img2{
padding-top: 25px;
}
.Player1,.Player2{
font-size: 32px;
text-align: left;
}
Binary file added CODE AVATARS/success.mp3
Binary file not shown.