Skip to content

Commit

Permalink
Main V0 Beta
Browse files Browse the repository at this point in the history
  • Loading branch information
na7la authored Dec 20, 2021
0 parents commit 8a43ef4
Show file tree
Hide file tree
Showing 10 changed files with 608 additions and 0 deletions.
25 changes: 25 additions & 0 deletions end.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.13.1/css/all.css" integrity="sha384-xxzQGERXS00kBmZW/6qxqJPyxW3UR0BPsL4c8ILaIWXva5kFi7TxkIIaMiKtqV1Q" crossorigin="anonymous">
</head>
<body>
<div class="container">
<div id="end" class="flex-center flex-column">
<h1 id="finalScore">0</h1>
<form class="end-form-container">
<h2 id="end-text">Enter your name below to save your score!</h2>
<input type="text" name="name" id="username" placeholder="Enter your name">
<button class="btn" id="saveScoreBtn" type="submit" onclick="saveHighScore(event)" disabled>Save</button>
</form>
<a href="/NFT_quizz_Beta/game.html" class="btn">Play Again</a>
<a href="/NFT_quizz_Beta" class="btn">Go Home<i class="fas fa-home"></i></a>
</div>
</div>
<script src="end.js"></script>
</body>
</html>
36 changes: 36 additions & 0 deletions end.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const username = document.querySelector('#username')
const saveScoreBtn = document.querySelector('#saveScoreBtn')
const finalScore = document.querySelector('#finalScore')
const mostRecentScore = localStorage.getItem('mostRecentScore')

const highScores = JSON.parse(localStorage.getItem('highScores')) || []

const MAX_HIGH_SCORES = 5

finalScore.innerText = mostRecentScore

username.addEventListener('keyup', () => {
saveScoreBtn.disabled = !username.value
})

saveHighScore = e => {
e.preventDefault()

const score = {
score: mostRecentScore,
name: username.value
}

highScores.push(score)

highScores.sort((a,b) => {
return b.score - a.score
})

highScores.splice(5)

localStorage.setItem('highScores', JSON.stringify(highScores))
window.location.assign('/NFT_quizz_Beta/')


}
74 changes: 74 additions & 0 deletions game.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
body {
color: #fff;
}

.choice-container {
display: flex;
margin-bottom: 0.8rem;
width: 100%;
border-radius: 4px;
background: rgb(18, 93, 255);
font-size: 3rem;
min-width: 80rem;
}

.choice-container:hover {
cursor: pointer;
box-shadow: 0 0.4rem 1.4rem 0 rgba(6, 103, 247, 0.5);
transform: scale(1.02);
transform: transform 100ms;
}

.choice-prefix {
padding: 2rem 2.5rem;
color: white;
}

.choice-text {
padding: 2rem;
width: 100%;
}

.correct {
background: linear-gradient(32deg, rgba(11, 223, 36) 0%, rgb(41, 232, 111) 100%);
}

.incorrect {
background: linear-gradient(32deg, rgba(230, 29, 29, 1) 0%, rgb(224, 11, 11, 1) 100%);
}

/* Heads up Display */
#hud {
display: flex;
justify-content: space-between;
}

.hud-prefix {
text-align: center;
font-size: 2rem;
}

.hud-main-text {
text-align: center;
}

#progressBar {
width: 20rem;
height: 3rem;
border: 0.2rem solid rgb(11,223,36);
margin-top: 2rem;
border-radius: 50px;
overflow: hidden;
}

#progressBarFull {
height: 100%;
background: rgb(11,223,36);
width: 0%;
}

@media screen and (max-width: 768px) {
.choice-container {
min-width: 40rem;
}
}
52 changes: 52 additions & 0 deletions game.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Quiz Page</title>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="game.css">
</head>
<body>
<div class="container">
<div id="game" class="justify-center flex-column">
<div id="hud">
<div class="hud-item">
<p id="progressText" class="hud-prefix">
Question
</p>
<div id="progressBar">
<div id="progressBarFull"></div>
</div>
</div>
<div class="hud-item">
<p class="hud-prefix">
Score
</p>
<h1 class="hud-main-text" id="score">
0
</h1>
</div>
</div>
<h1 id="question">What is the answer to this question</h1>
<div class="choice-container">
<p class="choice-prefix">A</p>
<p class="choice-text" data-number="1">Choice</p>
</div>
<div class="choice-container">
<p class="choice-prefix">B</p>
<p class="choice-text" data-number="2">Choice 2</p>
</div>
<div class="choice-container">
<p class="choice-prefix">C</p>
<p class="choice-text" data-number="3">Choice 3</p>
</div>
<div class="choice-container">
<p class="choice-prefix">D</p>
<p class="choice-text" data-number="4">Choice 4</p>
</div>
</div>
</div>
<script src="game.js"></script>
</body>
</html>
Loading

0 comments on commit 8a43ef4

Please sign in to comment.