Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 653b583

Browse files
Merge pull request #5 from Sanjulapro/master
Dice Roll Game
2 parents f3f223a + bcd512b commit 653b583

File tree

4 files changed

+51
-0
lines changed

4 files changed

+51
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Dice Roll Programming For Web Browser Games</title>
6+
<link rel="stylesheet" href="style.css">
7+
<script src="app.js "></script>
8+
</head>
9+
<body>
10+
<div id="die1" class="dies">0</div>
11+
<div id="die2" class="dies">0</div>
12+
<button onclick="rolldice()">Roll Dice</button>
13+
<h2 id="status" style="clear: left"></h2>
14+
</body>
15+
</html>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
function rolldice() {
2+
var die1 = document.getElementById("die1");
3+
var die2 = document.getElementById("die2");
4+
var status = document.getElementById("status");
5+
var d1 = Math.floor(Math.random() * 6) + 1;
6+
var d2 = Math.floor(Math.random() * 6) + 1;
7+
var diceTotal = d1 + d2;
8+
die1.innerHTML = d1;
9+
die2.innerHTML = d2;
10+
status.innerHTML = "You rolled "+diceTotal+ ".";
11+
if (d1 == d2){
12+
status.innerHTML += "Doubles! You get a free turn!!";
13+
}
14+
15+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.dies{
2+
float: left;
3+
width: 32px;
4+
background: #f5f5f5;
5+
border: gold 1px solid;
6+
padding: 10px;
7+
font-size: 24px;
8+
text-align: center;
9+
margin: 5px;
10+
color: blue;
11+
}
12+
.div button{
13+
width: 10px;
14+
}
15+
body{
16+
background-color: aquamarine;
17+
}

‎Dice-Roll-Game/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Dice-Roll-Game
2+
<b>Dice Roll Programming For Web Browser Games Using JavaScript</b><br><br>
3+
# Simple game using JS<br>
4+
There is a button name "Roll Dice" when it clicked the two dices are spinning. when output numbers are same return the sum of two numbers and saying the numbers are same you get free spin.. Otherwise return the sum of two numbers.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /