Let's choose a track and your hedgehog to start the race! You will need to accelerate your racer by clicking an acceleration button. A live updated leaderboard will show player positions and their progress on the track. You still have time to win, just accelerate to be the winner! Finally, when the hedgehogs finish the race, the results will be displayed and you will know who is the winner!
This is the final project of the Intermediate JavaScript Nanodegree Program from Udacity. The main purpose of this is to use Asynchronous Programming with JavaScript. Promises are the primary method for dealing with API responses in this game. And Async/Await syntax are used with API calls and internal logic to handle game processes.
A pre-built API provided by Udacity will create the race selected by the players and return a stream of information lasting the duration of the race, resulting in a final ranking of racers. The API is provided in the form of a binary so that you can run it on any system. Because of this, you cannot edit the API in any way, it is just a black box that we interact with via the API endpoints.
-
The first step you need to do is clone this repository.
-
To run the server, locate your operating system and run the associated command in your terminal at the root of the project.
Your OS | Command to start the API |
---|---|
Mac | ORIGIN_ALLOWED=http://localhost:3000 ./bin/server-osx |
Windows | ORIGIN_ALLOWED=http://localhost:3000 ./bin/server.exe |
Linux (Ubuntu, etc..) | ORIGIN_ALLOWED=http://localhost:3000 ./bin/server-linux |
If you are using a windows machine:
cd
into the root of the project containing data.json- Run the following command to add the environment variable:
set DATA_FILE=./data.json
Note that this process will use your terminal tab, so you will have to open a new tab and navigate back to the project root to start the front end.
- Top start the frontend, open another terminal tab and being at the root of this project, install the dependencies by running
npm install && npm start
. So, you should be able to access http://localhost:3000.