bruh moment
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<!DOCTYPE html>
|
||||
<!--
|
||||
Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
Click nbfs://nbhost/SystemFileSystem/Templates/Other/html.html to edit this template
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<title>Dice</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
</head>
|
||||
<body>
|
||||
<label id="valueOutput"></label><br>
|
||||
<label id="cpuText">CPU Die:<br></label>
|
||||
<label id="cpuDie"></label>
|
||||
<label id="PlayerText">Your Die:<br></label>
|
||||
<label id="playerDie"></label>
|
||||
<br>
|
||||
<label id="input"><input type="button" onclick="rollDie()" value="Roll Die"/></label>
|
||||
</body>
|
||||
<script>
|
||||
function printDie(dieNumber, elementId) {
|
||||
let filename = "DieSet/Die" + dieNumber + ".png";
|
||||
document.getElementById(elementId).innerHTML += "<image src=" + filename + ">";
|
||||
}
|
||||
function rollDie() {
|
||||
document.getElementById("playerDie").innerHTML = "";
|
||||
let diceTotal = 0;
|
||||
for (let i =0; i < 2; i++) {
|
||||
let dieValue = Math.trunc((Math.random() * 6) + 1);
|
||||
printDie(dieValue, "playerDie");
|
||||
diceTotal += dieValue;
|
||||
}
|
||||
writeValue(diceTotal);
|
||||
}
|
||||
function writeValue(yourDiceRoll) {
|
||||
document.getElementById("valueOutput").innerHTML = "Your Dice roll: " + yourDiceRoll
|
||||
}
|
||||
</script>
|
||||
</html>
|
Reference in New Issue
Block a user