https://github.com/simonapiz/find-your-hat
An Interactive Terminal Game with JavaScript and User Input
https://github.com/simonapiz/find-your-hat
codecademy-solutions javascript node terminal-game
Last synced: about 2 months ago
JSON representation
An Interactive Terminal Game with JavaScript and User Input
- Host: GitHub
- URL: https://github.com/simonapiz/find-your-hat
- Owner: SimonaPiz
- Created: 2022-02-18T10:53:07.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-05-11T14:11:56.000Z (about 3 years ago)
- Last Synced: 2025-04-07T00:48:28.267Z (about 1 year ago)
- Topics: codecademy-solutions, javascript, node, terminal-game
- Language: JavaScript
- Homepage:
- Size: 2.11 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Find Your Hat
> An interactive terminal game with JavaScript classes and user input
### Demo

## Table of contents
* [About this project](#about-this-project)
* [Objective](#objective)
* [Technologies](#technologies)
* [Setup](#setup)
## About this project
In this project, I build an interactive terminal game. The scenario is that the player has lost their hat in a field full of holes, and they must navigate back to it without falling down one of the holes or stepping outside of the field.
## Objective
### Implement Field
The project is centered on a Field class. Use a two-dimensional array representing the “field” itself. A field consists of a grid containing:
- “holes” (`O`)
- one “hat” (`^`)
- a neutral background character (`░`) to indicate the rest of the field itself.
- The player will begin in the upper-left of the field, and the player’s path is represented by (`*`).
`.generateField()` static method should at least take arguments for height and width of the field, and it should return a randomized two-dimensional array representing the field with a hat and one or more holes.
> extra: add a third argument used to determine what percent of the field should be covered in holes.
### Implement User Input
The game should be playable by users:
- When a user runs **main.js**, they should be prompted for input and be able to indicate which direction they’d like to “move”.
- After entering an instruction, the user should see a printed result of their current field map with the tiles they have visited marked with `*`. They should be prompted for their next move.
This should continue until the user either:
- Wins by finding their hat.
- Loses by landing on (and falling in) a hole.
- Attempts to move “outside” the field.
## Technologies
- JavaScript
- Node.js
- prompt-sync 4 - (*A sync prompt for node*)
## Setup
To run this project, install it locally using npm:
```
$ cd ../[directory]
$ npm install
$ node main.js
```