Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

look good #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 18 additions & 19 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8">
<title>Wikihow game</title>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<link href="https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,400;0,500;1,400;1,500&display=swap" rel="stylesheet">
</head>
<body>
<div id="instructions">
Expand All @@ -16,34 +16,33 @@ <h4>How to play:</h4>
<li>Use the "hint" button to get another image from the article to help your guess, you may only use 4 hints per game</li>
<li>The game ends when you either run out of lives or the timer runs out of time</li>
</ul>
<button id="start_button" class="btn btn-info" onclick="startGame()" disabled>
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
loading...
</button>
<button id="start_button" onclick="startGame()" disabled>Loading...</button>
</div>
<div id="game_div">
<div id="image_display"></div>
<div id="options_display"></div>
<div id="hint_display">
<button id="hint_button" class="btn btn-info" onclick="displayHint()">Get a hint (<b id="hints_left"></b> left)</button>
</div>
<div id="stats_box">
<div id="timer_container">
<img alt="timer icon" src="timer.svg"/>
<h4><b id="timer_display"></b></h4>
<div class="not-img-box">
<div id="options_display"></div>
<div id="hint_display">
<button id="hint_button" onclick="displayHint()">Get a hint (<b id="hints_left"></b> left)</button>
</div>
<div id="stats_box">
<div id="timer_container">
<img alt="timer icon" src="timer.svg"/>
<h4><b id="timer_display"></b></h4>
</div>
<h4><b id="score"></b> points</h4>
<h4><b id="health"></b> lives</h4>
</div>
<h4><b id="score"></b> points</h4>
<h4><b id="health"></b> lives</h4>
</div>
</div>
<div id="post_game_div" class="center_div">
<div id="post_game_div" class="center">
<h2>Game over!</h2>
<h4>Your score: <b id="post_score"></b></h4>
<button onclick="startGame()" class="btn btn-info">Play again</button>
<button onclick="startGame()">Play again</button>
</div>
<a href="https://github.com/Themis3000/wikihow_guess" target="_blank">
<img id="git_link" alt="github logo" src="github_logo.svg"/>
<div id="git_link"><img alt="github logo" src="github_logo.svg"/></div>
</a>
<script src="script.js"></script>
</body>
</html>
</html>
13 changes: 10 additions & 3 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,28 @@ let timer;
let hints;

let gameDataRequest = new XMLHttpRequest();

gameDataRequest.onreadystatechange = function() {
if (gameDataRequest.readyState === 4 && gameDataRequest.status === 200) {
gameData = JSON.parse(gameDataRequest.responseText);
let startButton = document.getElementById('start_button');
startButton.innerText = "Play";
startButton.disabled = false;
}
}
};

gameDataRequest.ontimeout = function() {
alert("timed out hecc");
};

gameDataRequest.timeout = 5000;
gameDataRequest.open("GET", "/wikihow_guess/articles_dir.txt");
gameDataRequest.send();

function startGame() {
instructionsDiv.style.display = "none";
postGameDiv.style.display = "none";
gameDiv.style.display = "block";
gameDiv.style.display = "flex";
hints = 4;
health = 3;
points = 0;
Expand Down Expand Up @@ -142,4 +149,4 @@ function timerTimeoutHandler() {
} else {
endGame();
}
}
}
105 changes: 89 additions & 16 deletions style.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,47 @@
html, body {
padding: 0;
background-color: #111;
color: #EEE;
font-family: 'Montserrat', sans-serif;
}

button {
border: none;
outline: none;
border-radius: 5px;
background-color: #333;
color: #FFF;
padding: 5px 10px 5px 10px;
transition: background-color 0.2s ease-in-out;
border-radius: 50000px;
cursor: pointer;
font-family: inherit;
}

button[disabled] {
background-color: #A22;
cursor: default;
color: #CCC;
}

button:hover:not([disabled]) {
background-color: #28F;
}

#start_button {
position: absolute;
width: 75%;
font-size: 3em;
right: 12.5%;
margin-top: 2em;
}

#game_div {
display: none;
flex-direction: column;
align-content: space-between;
align-items: stretch;
height: 90vh;
}

#post_game_div {
Expand All @@ -9,38 +51,53 @@
#stats_box {
display: flex;
flex-direction: row;
justify-content: space-evenly;
justify-content: space-between;
align-items: center;
}

#stats_box > * {
flex-basis: 33%;
}

#stats_box > :nth-child(2) {
text-align: center;
}

#stats_box > :last-child {
text-align: right;
}

#image_display {
display: flex;
flex-direction: row;
justify-content: center;
justify-content: space-evenly;
flex-wrap: wrap;
align-content: space-between;
}

#options_display {
#image_display img {
display: flex;
flex-direction: row;
justify-content: center;
border: #0F0 2px solid;
border-radius: 20px;
}

.option {
flex-grow: 1;
padding: 5px;
margin:0 1px;
#options_display {
display: flex;
flex-direction: row;
justify-content: space-around;
margin: 20px 0 20px 0;
}

#timer_container {
display: flex;
justify-content: center;
justify-content: flex-start;
align-items: center;
}

#timer_display {
padding: 5px;
margin:0 1px;
margin: 0 1px;
width: 20px;
}

#hint_display {
Expand All @@ -51,14 +108,30 @@
height: 48px;
width: 48px;
position: absolute;
bottom: 0;
right: 0;
margin: 20px;
bottom: 20px;
right: 20px;
background: #AF1700;
background: linear-gradient(141deg, #F20 10%, #EDFF00 40%, #62FF4E 65%, #00FFF8 92%);
padding: 5px;
border-radius: 200px;
transition: transform 0.2s ease-in-out;
}

.center_div {
#git_link:hover {
transform: scale(1.15);
}

.center {
margin: auto;
width: 50%;
padding: 10px;
text-align: center;
}
}

.option {
display: flex;
flex-basis: 15%;
justify-content: center;
align-items: center;
}