-
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
1 parent
f99edfe
commit 94528a2
Showing
12 changed files
with
269 additions
and
0 deletions.
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 |
---|---|---|
@@ -0,0 +1,77 @@ | ||
let numeroSecreto = 0; | ||
let intentos = 0; | ||
let listaNumerosSorteados = []; | ||
let numeroMaximo = 10; | ||
|
||
|
||
|
||
function asignarTextoElemento(elemento, texto) { | ||
let elementoHTML = document.querySelector(elemento); | ||
elementoHTML.innerHTML = texto; | ||
return; | ||
} | ||
|
||
function verificarIntento() { | ||
let numeroDeUsuario = parseInt(document.getElementById('valorUsuario').value); | ||
|
||
if (numeroDeUsuario === numeroSecreto) { | ||
asignarTextoElemento('p',`Acertaste el número en ${intentos} ${(intentos === 1) ? 'vez' : 'veces'}`); | ||
document.getElementById('reiniciar').removeAttribute('disabled'); | ||
} else { | ||
//El usuario no acertó. | ||
if (numeroDeUsuario > numeroSecreto) { | ||
asignarTextoElemento('p','El número secreto es menor'); | ||
} else { | ||
asignarTextoElemento('p','El número secreto es mayor'); | ||
} | ||
intentos++; | ||
limpiarCaja(); | ||
} | ||
return; | ||
} | ||
|
||
function limpiarCaja() { | ||
document.querySelector('#valorUsuario').value = ''; | ||
document.querySelector('#valorUsuario').focus (); | ||
} | ||
|
||
function generarNumeroSecreto() { | ||
let numeroGenerado = Math.floor(Math.random()*numeroMaximo)+1; | ||
|
||
console.log(numeroGenerado); | ||
console.log(listaNumerosSorteados); | ||
//Si ya sorteamos todos los números | ||
if (listaNumerosSorteados.length == numeroMaximo) { | ||
asignarTextoElemento('p','Ya se sortearon todos los números posibles'); | ||
} else { | ||
//Si el numero generado está incluido en la lista | ||
if (listaNumerosSorteados.includes(numeroGenerado)) { | ||
return generarNumeroSecreto(); | ||
} else { | ||
listaNumerosSorteados.push(numeroGenerado); | ||
return numeroGenerado; | ||
} | ||
} | ||
} | ||
|
||
function condicionesIniciales() { | ||
|
||
asignarTextoElemento('p',`Indica un número del 1 al ${numeroMaximo}`); | ||
numeroSecreto = generarNumeroSecreto(); | ||
intentos = 1; | ||
console.log(numeroSecreto); | ||
} | ||
|
||
function reiniciarJuego() { | ||
//limpiar caja | ||
limpiarCaja(); | ||
//Indicar mensaje de intervalo de números | ||
//Generar el número aleatorio | ||
//Inicializar el número intentos | ||
condicionesIniciales(); | ||
//Deshabilitar el botón de nuevo juego | ||
document.querySelector('#reiniciar').setAttribute('disabled','true'); | ||
|
||
} | ||
|
||
condicionesIniciales(); |
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.
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,55 @@ | ||
<!DOCTYPE html> | ||
<html lang="es"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta name="author" content="Eduardo Iuorio"> | ||
<meta name="keywords" | ||
content="Eduardo Iuorio, eduardo iuorio, programador, programador front end, programador back end, front end, back end, secret game, el juego secreto, secreto"> | ||
<meta name="copyright" content="Copyright Eduardo Iuorio"> | ||
<title>Secret Game</title> | ||
<link rel="preconnect" href="https://fonts.googleapis.com"> | ||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> | ||
<link href="https://fonts.googleapis.com/css2?family=Chakra+Petch:wght@700&family=Inter:wght@400;700&display=swap" | ||
rel="stylesheet"> | ||
<link rel="stylesheet" href="style.css"> | ||
|
||
</head> | ||
|
||
<body> | ||
|
||
<div class="container"> | ||
|
||
<div class="container__contenido"> | ||
|
||
<div class="container__informaciones"> | ||
<div class="container__texto"> | ||
|
||
<p class="texto__parrafo"></p> | ||
</div> | ||
<input type="number" id="valorUsuario" min="1" max="10" class="container__input"> | ||
<div class="chute container__botones"> | ||
<button onclick="verificarIntento();" class="container__boton">Intentar</button> | ||
<button onclick="reiniciarJuego();" class="container__boton" id="reiniciar" disabled>Nuevo | ||
juego</button> | ||
</div> | ||
|
||
</div> | ||
|
||
</div> | ||
</div> | ||
|
||
|
||
<div class="piramide"> | ||
<h1 class="linea1">Juego</h1> | ||
<h1 class="linea2">del</h1> | ||
<h1 class="linea3">número</h1> | ||
<h1 class="linea4">secreto</h1> | ||
</div> | ||
<script src="app.js"></script> | ||
|
||
</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,137 @@ | ||
|
||
|
||
* { | ||
box-sizing: border-box; | ||
margin: 0; | ||
padding: 0; | ||
color: white; | ||
cursor: pointer; | ||
|
||
} | ||
|
||
body { | ||
background: linear-gradient(#1354A5 0%, #041832 33.33%, #041832 66.67%, #01080E 100%); | ||
display: flex; | ||
align-items: center; | ||
justify-content:center; | ||
} | ||
|
||
.container { | ||
width: 1200px; | ||
height: 650px; | ||
background-image: url("img/niños.jpeg"); | ||
background-repeat: no-repeat; | ||
background-size: 100% 100%; | ||
position: relative; | ||
} | ||
|
||
|
||
.container__contenido { | ||
display: flex; | ||
align-items: center; | ||
position: relative; | ||
bottom: -49%; | ||
} | ||
|
||
.container__informaciones { | ||
flex: 1; | ||
padding: 3rem; | ||
|
||
} | ||
|
||
.container__boton { | ||
border-radius: 16px; | ||
background: #1875E8; | ||
padding: 16px 24px; | ||
width: 100%; | ||
font-size: 24px; | ||
font-weight: 700; | ||
border: none; | ||
margin-top: 2rem; | ||
|
||
} | ||
|
||
.container__boton:disabled { | ||
background: #898989; | ||
|
||
} | ||
|
||
.container__texto { | ||
margin: 16px 0 16px 0; | ||
} | ||
|
||
.container__texto-azul { | ||
color: #1875E8; | ||
} | ||
|
||
.container__input { | ||
width: 100%; | ||
height: 50px; | ||
border-radius: 16px; | ||
background-color: #FFF; | ||
border: none; | ||
color: #1875E8; | ||
padding: 1rem; | ||
font-size: 24px; | ||
font-weight: 700; | ||
font-family: 'Inter', sans-serif; | ||
} | ||
|
||
|
||
|
||
.container__botones { | ||
display: flex; | ||
gap: 2em; | ||
|
||
} | ||
|
||
h1 { | ||
font-family: 'Chakra Petch', sans-serif; | ||
font-size: 72px; | ||
padding-bottom: 1rem; | ||
} | ||
|
||
p, | ||
button { | ||
font-family: 'Inter', sans-serif; | ||
|
||
|
||
} | ||
|
||
.texto__parrafo { | ||
font-size: 30px; | ||
font-weight: 850; | ||
display: flex; | ||
justify-content: center; | ||
color: yellow; | ||
padding: 9px; | ||
border: 1px solid color(yellow red green blue); | ||
border-radius: 15px; | ||
box-shadow: 0px 20px 29px -5px ; | ||
} | ||
|
||
.piramide { | ||
text-align: center; | ||
line-height: 1.5; | ||
margin-top: 50px; | ||
} | ||
|
||
.piramide h1 { | ||
margin: 0; | ||
} | ||
|
||
.linea1 { | ||
margin-left: 35%; | ||
} | ||
|
||
.linea2 { | ||
margin-left: 30%; | ||
} | ||
|
||
.linea3 { | ||
margin-left: 25%; | ||
} | ||
|
||
.linea4 { | ||
margin-left: 20%; | ||
} |