This project is a competitive two-player trivia game built with HTML, CSS, and JavaScript. It allows two players to answer trivia questions fetched from The Trivia API. Players take turns answering questions from selected categories and compete for the highest score. The game ends when all categories are exhausted or players decide to end it early.
-
Player Setup:
- Players input their names to start the game.
-
Category Selection:
- Players choose a category from a list fetched from the trivia API.
- Categories are dynamically fetched and cannot be repeated.
-
Question Difficulty Levels:
- The game fetches questions of varying difficulty (easy, medium, hard) for each category.
- Each difficulty level contains 2 questions.
-
Scoring System:
- Correct answers are rewarded based on question difficulty:
- Easy: 10 points
- Medium: 15 points
- Hard: 20 points
- Correct answers are rewarded based on question difficulty:
-
End Game Options:
- Players can select a new category or end the game after each set of questions.
- The game declares a winner based on the final scores.
-
Dynamic Question Display:
- Players take turns answering questions.
- The correct answers are validated, and scores are updated in real-time.
-
Player Setup:
- Players enter their names and click "Start Game."
-
Category Selection:
- The game fetches available categories from The Trivia API.
- Players select a category to proceed.
-
Answering Questions:
- Players alternate turns answering questions.
- The difficulty of the questions (easy, medium, hard) increases after every two questions.
-
Scoring:
- Points are awarded based on the correctness of the answers and the difficulty of the question.
-
End of Game:
- Players can end the game or continue with a new category.
- The game ends automatically if all categories are used, and the winner is announced.
- HTML: Structure of the game interface.
- CSS: Basic styling for layout and design.
- JavaScript: Core logic for fetching data, managing game flow, and handling player interactions.
- The Trivia API: Used to fetch categories and trivia questions.
-
Clone the repository or download the files:
https://github.com/vvssgowtham/TwoPlayerTriviaGame.git
-
Navigate to the project directory:
cd TwoPlayerTriviaGame
-
Open
index.html
in your web browser. -
Enter player names and start the game.
- The Trivia API: This API provides the trivia questions and categories. The game uses the API to fetch questions based on selected categories and difficulty levels.
- API Endpoint:
https://the-trivia-api.com/v2/questions
- API Endpoint:
Enjoy playing the Two-Player Trivia Battle Game! Feel free to contribute or suggest improvements.