Git Product home page Git Product logo

hangman-game's Introduction

Disney Hangman

A Disney twist on a classic game.

How to Play

Press on any key to get started.

How it Works

  1. Once a player presses down on a key, a function is called to iterate over a set array of Disney-related words and randomly select which word to feature.
  2. The following function is used to iterate through the selected word, via for loop, and replace each letter with a dash for (var i = 0; i < disneyWords[currentWordIndex].length; i++) { guessingWord.push("_"); }
  3. A const exists to give a player a max amount of tries, which is 10.
  4. Each letter guessed is pushed into an array and displayed on the page.
  5. A function iterates over the randomly selected word and if a guessed letter is exists in that word, the dash is replaced.
  6. The following function checks to see if the player has correctly guessed the word and adds to the wins counter: function checkWin() { if(guessingWord.indexOf("_") === -1) { document.getElementById("pressKeyTryAgain").style.cssText= "display: block"; wins++; hasFinished = true; } };
  7. Afterwards, the variable hasFinished is set to true, which then initiates this function: document.onkeydown = function(event) { // Restart game when player has typed a new letter if(hasFinished) { resetGame(); hasFinished = false; } else { // ONLY allowing the alphabet if(event.keyCode >= 65 && event.keyCode <= 90) { makeGuess(event.key.toLowerCase()); } } };

Technologies Used

  • JavaScript
  • Bootstrap

hangman-game's People

Contributors

mapipina avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.