Skip to content

Instantly share code, notes, and snippets.

@wofockham
Created November 10, 2014 05:09
Show Gist options
  • Save wofockham/fdde9bf5cef866f8ef27 to your computer and use it in GitHub Desktop.
Save wofockham/fdde9bf5cef866f8ef27 to your computer and use it in GitHub Desktop.

Hangman LAB

The Hangman Game:

  • The game selects a random word from a word list and makes that the secret word
  • The player guesses one letter at a time, trying to figure out what the word is
  • If the player guesses correctly, any instances of that letter are revealed in the secret word
  • If the player guesses incorrectly, they are penalized by taking away a guess
  • If a player reveals all of the letters of the secret word, they win
  • If a player makes 8 incorrect guesses before solving the secret word, they lose

To do:

  • Plan out your object model. What variables and functions will each object have? How will the different objects communicate with each other?
  • Get the logic to work and make sure you have the game working in the console first before translating it over to update the DOM.
  • Translate your game over so it updates the DOM.
  • Once you get the game working:
    • Implement a "reset" button that will reset the game and choose a new word
    • Implement a "give up" button that will show the solution
  • Are there ways to refactor your code to make it DRYer?

###Bonus:

  • Validate the input so that only single letters are accepted as guesses
  • Change the input format so that there is no text field. You can get input by "listening" to the keyup event and figuring out which key was pressed.
  • Draw the hanged man guy using CSS
  • Animate the actual moment of execution with frighteningly gruesome detail
  • Implement a "hint" button that will reveal one of the letters in the word
  • Provide a backend to keep track of scores, and an admin to manage the list of possible words.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment