A simple Hangman Game I made for fun to be played in the terminal. It uses an API from API Ninjas to get a random word each time the game is ran or restarted.
The player does have to get an api key in order to play the game (It is free and you get 10,000 calls each month).
It's pretty easy! All you have to do is:
- Go to https://api-ninjas.com/
- Click the "Get a Free API Key" button
- Make an account and get your email verified
- From the "My Account" page, copy the API Key That's it!
Now that you have your API Key, all you need to do is go to the Hangman Game folder, navigate into the public folder and open "word.js". Once you're in the file, look for this line:
//ADD YOUR OWN API_KEY BELOW FROM https://api-ninjas.com/
const apiKey = config.API_KEY;
All you have to do is replace the "config.API_KEY" with your API Key in quotations. After you're done it should look like this:
//ADD YOUR OWN API_KEY BELOW FROM https://api-ninjas.com/
const apiKey = "EXAMPLE_API$KEY";
There's two ways of running the game:
- BASH file (using the ./ command)
- Open up terminal (MacOS) or Command Prompt (Windows), navigate to where this Hangman Game folder resides using
cd
command - Then just run the command
./runHangman
in your terminalIf it says something like "Permission Denied" then you will have to run
chmod +x runHangman
and then retry
- NodeJS file (using node command)
- Open up terminal (MacOS) or Command Prompt (Windows), navigate to where this Hangman Game folder resides using
cd
command - Then go into the public folder using the
cd
command again - Now run
node main.js