-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
428 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
.snowpack | ||
build | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
let player1 = ""; | ||
let player2 = ""; | ||
let namesEntered = false; | ||
const buttonStart = document.querySelector("#buttonstart"); | ||
const buttonEnd = document.querySelector("#buttonend"); | ||
function validateNameType(playerName) { | ||
const regex = /^[a-zA-Z]+$/; | ||
return regex.test(playerName); | ||
} | ||
function validateNameZeroSymbol(playerName) { | ||
const regex = /^[a-zA-Z\s]*$/; | ||
return regex.test(playerName); | ||
} | ||
if (buttonStart && buttonEnd) { | ||
buttonStart.addEventListener("click", function() { | ||
if (!namesEntered) { | ||
player1 = prompt("What is your name Player 1") || ""; | ||
player2 = prompt("What is your name Player 2") || ""; | ||
while (true) { | ||
if (player1.length > 0 && player1.length <= 10 && validateNameType(player1) && validateNameZeroSymbol(player1) && player2.length > 0 && player2.length <= 10 && validateNameType(player2) && validateNameZeroSymbol(player2)) { | ||
namesEntered = true; | ||
break; | ||
} else { | ||
if (player1.length === 0 || player1.length > 10 || !validateNameType(player1) || !validateNameZeroSymbol(player1)) { | ||
player1 = prompt("Invalid input for Player 1. Please enter a valid name (up to 10 characters, only letters, no symbols)") || ""; | ||
} | ||
if (player2.length === 0 || player2.length > 10 || !validateNameType(player2) || !validateNameZeroSymbol(player2)) { | ||
player2 = prompt("Invalid input for Player 2. Please enter a valid name (up to 10 characters, only letters, no symbols)") || ""; | ||
} | ||
} | ||
} | ||
const player1Name = document.getElementById("Player1Name"); | ||
const player2Name = document.getElementById("Player2Name"); | ||
if (player1Name && player2Name) { | ||
player1Name.innerHTML = player1; | ||
player2Name.innerHTML = player2; | ||
} | ||
} | ||
if (buttonStart && buttonEnd) { | ||
buttonStart.style.display = "none"; | ||
buttonEnd.style.display = "block"; | ||
const dice_shake = new Audio("./source/audio/dice_shake.mp3"); | ||
dice_shake.play(); | ||
const a1 = document.querySelector(".img1"); | ||
const a2 = document.querySelector(".img2"); | ||
if (a1 && a2) { | ||
a1.style.animation = "rotate-center 1s linear both infinite"; | ||
a2.style.animation = "rotate-center 1s linear both infinite"; | ||
} | ||
} | ||
}); | ||
buttonEnd.addEventListener("click", () => { | ||
if (buttonEnd && buttonStart) { | ||
buttonEnd.style.display = "none"; | ||
buttonStart.style.display = "block"; | ||
const dice_roll = new Audio("./source/audio/dice_roll.mp3"); | ||
dice_roll.play(); | ||
const randomNumber1 = Math.floor(Math.random() * 6) + 1; | ||
const randomImageSource = "./source/images/dice" + randomNumber1 + ".png"; | ||
const image1 = document.querySelector(".img1"); | ||
if (image1) { | ||
image1.setAttribute("src", randomImageSource); | ||
} | ||
const randomNumber2 = Math.floor(Math.random() * 6) + 1; | ||
const randomImageSource2 = "./source/images/diceR" + randomNumber2 + ".png"; | ||
const image2 = document.querySelector(".img2"); | ||
if (image2) { | ||
image2.setAttribute("src", randomImageSource2); | ||
} | ||
const headingElement = document.querySelector("h1"); | ||
if (headingElement) { | ||
if (randomNumber1 > randomNumber2) { | ||
headingElement.innerHTML = "🎉🏆🎉" + player1 + " Wins!"; | ||
} else if (randomNumber2 > randomNumber1) { | ||
headingElement.innerHTML = player2 + " Wins 🎉🏆🎉"; | ||
} else { | ||
headingElement.innerHTML = "Draw!"; | ||
} | ||
} | ||
const a1 = document.querySelector(".img1"); | ||
const a2 = document.querySelector(".img2"); | ||
if (a1 && a2) { | ||
a1.style.animation = "rotate-end 1s ease-in-out both "; | ||
a2.style.animation = "rotate-end 1s ease-in-out both "; | ||
} | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
|
||
<!-- Title --> | ||
<title> 🎲 Dicee 🎲 </title> | ||
|
||
<!-- Favicon --> | ||
<link rel="icon" href="./source/images/logo.png"> | ||
|
||
<!-- Google Fonts --> | ||
<link | ||
href="https://fonts.googleapis.com/css2?family=Chakra+Petch&family=DynaPuff&family=Rubik+Dirt&family=Silkscreen&display=swap" | ||
rel="stylesheet"> | ||
|
||
<!-- Style --> | ||
<link rel="stylesheet" href="./source/styles/index.css"> | ||
|
||
<!-- Javascript --> | ||
<script type="module" src="/dist/index.js"></script> | ||
</head> | ||
|
||
<body> | ||
<div class="container"> | ||
<header class="dgrid"> | ||
<h1 class="title"> 🎲 Dicee 🎲 </h1> | ||
</header> | ||
|
||
<main> | ||
<section class="mainContainer "> | ||
<figure class="dice main-animation dgrid"> | ||
<figcaption> | ||
<p class="paragraf" id="Player1Name">Player 1</p> | ||
</figcaption> | ||
<img id="imgPlayer1" class="img img1" src="./source/images/dice6.png" alt="Dice"> | ||
</figure> | ||
|
||
<figure class="dice dgrid"> | ||
<figcaption> | ||
<p class="paragraf" id="Player2Name">Player 2</p> | ||
</figcaption> | ||
<img id="imgPlayer2" class="img img2" src="./source/images/diceR6.png" alt="Dice"> | ||
</figure> | ||
</section> | ||
|
||
<section> | ||
<button id="buttonstart" class="button">Start</button> | ||
<button id="buttonend" class="button">End</button> | ||
</section> | ||
|
||
<section class="github"> | ||
<a href="https://github.com/L3on06" target="_blank"> | ||
<figure> | ||
<img src="./source/images/github.svg" alt="Github"> | ||
</figure> | ||
</a> | ||
</section> | ||
</main> | ||
|
||
<!-- Background animation --> | ||
<ul class="circles"> | ||
<li></li> | ||
<li></li> | ||
<li></li> | ||
<li></li> | ||
<li></li> | ||
<li></li> | ||
<li></li> | ||
<li></li> | ||
<li></li> | ||
<li></li> | ||
</ul> | ||
</div> | ||
|
||
</body> | ||
|
||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# https://www.robotstxt.org/robotstxt.html | ||
User-agent: * | ||
Disallow: |
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.