html
html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<!DOCTYPE html>
<html lang="en-GB">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<title>Guess Game</title>
</head>
<body>
<fieldset class="out" id="info">
<legend id="lInfo">Guess Game</legend>
I am thinking of a number between 1 and 100<br>
I gave you 10 chances to guess it<br><br>
<q lang="quo" id="copy" style="color: #ee1280;">JFS=Animion</q>
</fieldset>
<div align="center">
<input id="input" type="text" placeholder="Enter your guess...">
<br>
<button id="button">Guess</button>
<button id="playgain">Play Again</button>
</div>
<fieldset class="out" id="output">
<legend id="lOutput">Updates</legend>
More Update Coming Soon!<br><br>
<span id="light" style="color:red">v2.1:</span><br>
» Added vibration for inputing wrong guesses<br><br>
Enter to Rename, Shift+Enter to Preview
css
css
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
html
{
background: #007;
box-shadow: inset 0px 0px 10px 4px #06f;
height: 100%;
font-size: 12px;
}
.out
{
box-shadow: 0px 0px 5px 2px #ff0;
color: #ff0;
padding: 10px 30px;
margin: 20px;
margin-top: 10px;
background: #000;
border-radius: 8px;
border: none;
text-align: center;
}
legend
{
color: #000;
text-align: left;
font-size: 12px;
Enter to Rename, Shift+Enter to Preview
js
js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
window.onload = function startGame(){
mysteryNumber = Math.ceil(Math.random() * 100);
//console.log(mysteryNumber); //check answer
playersGuess = 0;
guessesRemaining = 10;
guessesMade = 0;
gameState = "";
gameWon = false;
//The input and output fields
input = document.querySelector("#input");
output = document.querySelector("#output");
button.style.display = "block";
playgain.style.display = "none";
button.onclick = function playGame()
{
playersGuess = parseInt(input.value);
gameLast = "<br><br><br>Recent Game Statistic:";
if (playersGuess > mysteryNumber && playersGuess < 101)
{
guessesRemaining = guessesRemaining - 1;
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run