Created
May 4, 2017 02:40
-
-
Save inlinestyle/0d52b18f694b1d8225a8a8a0ebf63541 to your computer and use it in GitHub Desktop.
Exported from Popcode. Click to import: https://popcode.org/?gist=0d52b18f694b1d8225a8a8a0ebf63541
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Hangman Starter</title> | |
</head> | |
<body> | |
<div id="container"> | |
<p id="message"></p> | |
<img id="hangman" src="https://github.com/ScriptEdcurriculum/solutions2016/blob/master/year1/unit13/project2/images/Hangman-0.png?raw=true"/> | |
<div id="word"></div> | |
<button id="newgame">New Game</button> | |
</div> | |
</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
{"enabledLibraries":["jquery"]} |
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
//On the lines below define four variables secretWord, guesses, misses, and images | |
// Set secretWord equal to null | |
// Set correctGuesses equal to an empty array | |
// Set wrongGuesses equal to an empty array | |
var secretWord = null; | |
var images = [ | |
"https://github.com/ScriptEdcurriculum/solutions2016/blob/master/year1/unit13/project2/images/Hangman-0.png?raw=true", | |
"https://github.com/ScriptEdcurriculum/solutions2016/blob/master/year1/unit13/project2/images/Hangman-1.png?raw=true", | |
"https://github.com/ScriptEdcurriculum/solutions2016/blob/master/year1/unit13/project2/images/Hangman-2.png?raw=true", | |
"https://github.com/ScriptEdcurriculum/solutions2016/blob/master/year1/unit13/project2/images/Hangman-3.png?raw=true", | |
"https://github.com/ScriptEdcurriculum/solutions2016/blob/master/year1/unit13/project2/images/Hangman-4.png?raw=true", | |
"https://github.com/ScriptEdcurriculum/solutions2016/blob/master/year1/unit13/project2/images/Hangman-5.png?raw=true", | |
"https://github.com/ScriptEdcurriculum/solutions2016/blob/master/year1/unit13/project2/images/Hangman-6.png?raw=true" | |
]; | |
// in the prepareGame() function below | |
// set correctGuesses to an empty array | |
// set wrongGuesses to an empty array | |
// call the drawWord() function | |
// call the drawHangman() function | |
// log the secret word to the console | |
function prepareGame() { | |
secretWord = ['J','A','V','A','S','C','R', 'I', 'P', 'T']; | |
} | |
// in this onWin() function below | |
// 1. alert "You won!" | |
function onWin() { | |
} | |
// in this onLose() function below | |
// 1. alert "You lost!" | |
function onLose() { | |
} | |
// in this checkIfWon() function below | |
// 1. Declare a variable hasAll and set equal to true | |
// 2. For each letter in secretWord | |
// a. if correctGuesses does not include the letter set variable hasAll to false | |
// 3. return hasAll | |
function checkIfWon() { | |
} | |
// in this checkIfLost() function below | |
// 1. declare a variable misses and set it equal to the length of wrongGuesses array | |
// 2. if misses is less than 6 return false else return true | |
function checkIfLost() { | |
} | |
// in the onCorrectGuess() function below | |
// 1. add the the letter variable to the array correctGuesses | |
// 2. call the drawWord function | |
// 3. if the checkIfWon() is returns true call the onWin() function | |
function onCorrectGuess(letter) { | |
} | |
// in the onWrongGuess() function below | |
// 1. add the the letter variable to the array wrongGuesses | |
// 2. call the drawHangman function | |
// 3. if the checkIfLost() function returns true call the onLose() function | |
function onWrongGuess(letter) { | |
} | |
// in the judgeGuess function below | |
// 1. if the letter is included in secretWord, call the onCorrectGuess(letter) function | |
// otherwise call onWrongGuess(letter) function | |
function judgeGuess(letter) { | |
} | |
// in the drawWord function below | |
// 1. empty the div tag with the id "word" | |
// 2. For each letter in secretWord | |
// if correctGuesses includes letter append the letter | |
// othewise append and underscore | |
function drawWord() { | |
} | |
// in the drawHangman function below | |
// 1. define a variable misses equal to the length of wrongGuesses | |
// 2. change the src of the img tag with the id hangman | |
// to the correct image url based on the number of misses | |
function drawHangman() { | |
} | |
// in the onKeyDown function below | |
// 1. define a variable letter an set it equal to the correct letter | |
// 2. set letter equal to the upperCase of itself | |
// 3. call the judgeGuess function with letter as an argument | |
function onKeyDown(event) { | |
} | |
// Call the prepare game function | |
// Initialize a jQuery keydown event handler | |
// (Keydown function should take onKeyDown function as an argument) | |
$(document).ready(function() { | |
}); |
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
body { | |
font-family: Arial, Helvetica, sans-serif; | |
} | |
#container { | |
width:40em; | |
margin:auto; | |
text-align:center; | |
} | |
#word { | |
font-size:5em; | |
letter-spacing:0.25em; | |
} | |
#message { | |
font-size:1.5em; | |
background-color:grey; | |
border-radius:2em; | |
padding:1em; | |
display:none; | |
} | |
#newgame { | |
display:none; | |
font-size:1.5em; | |
padding:0.5em; | |
margin:1em; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment