A simple web-based trivia game that challenges players with questions from various categories. Built with HTML, CSS, and JavaScript, this game fetches questions from the Open Trivia Database API and tracks the player's score. Perfect for anyone interested in mythology and trivia games.
- Trivia questions from multiple categories and difficulties
- Real-time score tracking
- User leaderboard showcasing top scores
- Responsive design for various devices
-
Clone the repository:
git clone https://github.com/your-username/mythology-trivia-game.git cd mythology-trivia-game
-
Install the dependencies:
cd Backend npm install
-
Set up environment variables:
Create a
.env
file in theBackend
directory and add the following:MONGO_URI=your_mongodb_connection_string PORT=your_desired_port (optional, default is 6000)
-
Start the server:
cd Backend npm run dev
The server will start on the port specified in the
.env
file or the default port 6000. -
Open the frontend:
Open
index.html
in your browser to start playing the game.
Submit a user's score.
-
Request:
{ "name": "PlayerName", "score": 100 }
-
Response:
{ "message": "Score submitted successfully" }
Retrieve the top 10 scores.
- Response:
[ { "name": "PlayerName1", "score": 150 }, { "name": "PlayerName2", "score": 120 }, ... ]
-
Frontend:
- HTML
- CSS
- JavaScript
-
Backend:
- Node.js
- Express
- Mongoose
- MongoDB
-
Dependencies:
cors
: Enables Cross-Origin Resource Sharingdotenv
: Loads environment variables from a.env
filenodemon
: Automatically restarts the server on file changes (development use)
Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.
This project is licensed under the MIT License. See the LICENSE file for details.