commit f1e358ac54def59cec83490661cfa411b6bdf62a Author: Lukáš Date: Wed Mar 6 18:36:31 2024 +0100 opravit tlačítka diff --git a/1zaokrouhleni.js b/1zaokrouhleni.js new file mode 100644 index 0000000..3591702 --- /dev/null +++ b/1zaokrouhleni.js @@ -0,0 +1,27 @@ +// Objekt Math +// console.log(Math.PI); +// console.log(Math.E); // erolovo číslo +// console.log(Math.SQRT1_2); // druhá odmocnina + +// console.log(Math.round(5.8)); // zaokrouhlování na celáčísla + +// console.log(Math.ceil(3.2)); // zaokrouhlení nahoru (třeba stránkování se vždy zaokrouhluje na horu) (ceil = strop) + +// console.log(Math.floor(2.8)); // zaokrouhlení dolů na celé číslo (Floor = podlaha) + +// const number = 15.1255; +// console.log(parseFloat(number.toFixed(3))); // určí počet na kolik čísel proměnou zaokrouhlit , parseFlout string převede na číslo + +// Náhoda +// console.log(Math.random()); // Náhpdné číslo od 0 do 1 +// console.log(Math.random()); + +// console.log(Math.random() * 6); // Náhodné číslo od 0 do 6 nezaokrůhloné +// console.log(Math.random() * 6); + +// console.log(Math.ceil(Math.random() * 6)); +// console.log(Math.ceil(Math.random() * 6)); // Náhodné číslo od 0 do 6 zaokrouhlené + +// console.log(Math.floor(Math.random() * 6) + 1); // Náhodné číslo od 1 do 6 +// console.log(Math.floor(Math.random() * 6) + 1); +// console.log(Math.floor(Math.random() * 6) + 1); diff --git a/colors.css b/colors.css new file mode 100644 index 0000000..e61b23c --- /dev/null +++ b/colors.css @@ -0,0 +1,5 @@ +:root { + --special-black: #141414; + --special-red: #e50914; + --special-white: #e5e5e5; +} diff --git a/img/1.jpg b/img/1.jpg new file mode 100644 index 0000000..efff6da Binary files /dev/null and b/img/1.jpg differ diff --git a/img/2.jpg b/img/2.jpg new file mode 100644 index 0000000..bb739a2 Binary files /dev/null and b/img/2.jpg differ diff --git a/img/3.jpg b/img/3.jpg new file mode 100644 index 0000000..cb6fdff Binary files /dev/null and b/img/3.jpg differ diff --git a/img/4.jpg b/img/4.jpg new file mode 100644 index 0000000..bb5a0a9 Binary files /dev/null and b/img/4.jpg differ diff --git a/img/5.jpg b/img/5.jpg new file mode 100644 index 0000000..5c8e4b9 Binary files /dev/null and b/img/5.jpg differ diff --git a/img/6.jpg b/img/6.jpg new file mode 100644 index 0000000..199598d Binary files /dev/null and b/img/6.jpg differ diff --git a/img/default.jpg b/img/default.jpg new file mode 100644 index 0000000..c37163e Binary files /dev/null and b/img/default.jpg differ diff --git a/index.html b/index.html new file mode 100644 index 0000000..8e5a37c --- /dev/null +++ b/index.html @@ -0,0 +1,24 @@ + + + + + + + Document + + + +
+ + +
+ +
+ Resetovat hru +
+ +
+ + + + diff --git a/script.js b/script.js new file mode 100644 index 0000000..866fa81 --- /dev/null +++ b/script.js @@ -0,0 +1,40 @@ +const btn = document.querySelector(".btn"); +const cubeImage = document.querySelector(".cube-image"); +const resultSection = document.querySelector(".result"); + +let counter = 0; +let clicks = 0; + +//Function +const paragraphToWebsite = (paragraphContent, whereToAdd) => { + const p = document.createElement("p"); + p.textContent = paragraphContent; + whereToAdd.append(p); +}; + +btn.addEventListener("click", () => { + const randomNumber = Math.floor(Math.random() * 6) + 1; // čísla jsou v názvu obrázku + cubeImage.src = "img/" + randomNumber + ".jpg"; + // counter = counter + randomNumber; + counter += randomNumber; // zkrácený zápis + + resultSection.textContent = ""; // vyčistí stránku + paragraphToWebsite(counter, resultSection); + + // Počet kliknutí - počet pokusů + clicks += 1; + + // přídání výherního textu + if (clicks < 5 && counter < 20) { + // Házejte dál + paragraphToWebsite("Házejte dál", resultSection); + } else if (clicks <= 5 && counter >= 20) { + // Vyhráli jste + paragraphToWebsite("Vyhráli jste", resultSection); + btn.style.visibility = "hidden"; + } else if (clicks == 5 && counter < 20) { + // Prohráli jste + paragraphToWebsite("Prohráli jste", resultSection); + btn.style.visibility = "hidden"; + } +}); diff --git a/style.css b/style.css new file mode 100644 index 0000000..87801cf --- /dev/null +++ b/style.css @@ -0,0 +1,58 @@ +@import url("colors.css"); + +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +body { + background-color: var(--special-black); +} + +.cube { + display: flex; + flex-direction: column; + align-items: center; +} + +.btn { + color: var(--special-white); + background-color: linear-gradient(#e50914, black); + padding: 5px 10px; + font-size: 18px; + margin-top: 20px; + margin-bottom: 20px; +} + +.result { + text-align: center; + margin-top: 20px; + /* Nastaví pevnou výšku tlačítka */ + height: 46px; +} + +.result p { + color: var(--special-white); + font-size: 20px; +} + +.reset-button { + display: flex; + flex-direction: row; + justify-content: center; +} + +.reset-button a { + color: #e5e5e5; + background-color: linear-gradient(black, #e50914); + padding: 5px 10px; + font-size: 18px; + margin-top: 20px; + text-decoration: none; +} + +.cube-image { + width: 122px; + height: 122px; +}