Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cooking Challenge game is added #4716

Merged
merged 4 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions Games/Cooking_Challenge_Game/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Cooking Challenge Game

Welcome to the Cooking Challenge Game! This is a simple web-based game where players must match a given order by selecting the correct ingredients within a limited time.

## Table of Contents

- [Installation](#installation)
- [Usage](#usage)
- [Game Mechanics](#game-mechanics)
- [Technologies Used](#technologies-used)
- [Contributing](#contributing)
- [License](#license)

## Installation

To get a copy of this project up and running on your local machine, follow these steps:

1. Clone the repository:
```bash
git clone https://github.com/yourusername/cooking-challenge-game.git
```
2. Navigate to the project directory:
```bash
cd cooking-challenge-game
```

## Usage

To start the game, simply open the `index.html` file in your preferred web browser.

## Game Mechanics

1. **Objective:**
- Match the order by selecting the correct ingredients within the given time limit.

2. **Controls:**
- Click on the ingredient icons to select them.
- Click the "Serve" button to check if the selected ingredients match the order.

3. **Scoring:**
- Each correct order gives you 10 points.
- The game lasts for 60 seconds. Your score is displayed at the end of the game.

## Technologies Used

- **HTML:** Structure of the game.
- **CSS:** Styling and layout.
- **JavaScript:** Game logic and interactivity.

## File Structure

```plaintext
.
β”œβ”€β”€ index.html
β”œβ”€β”€ styles.css
└── script.js
28 changes: 28 additions & 0 deletions Games/Cooking_Challenge_Game/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Cooking Challenge Game</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div id="gameContainer">
<div id="kitchen">
<div class="ingredient" id="tomato">πŸ…</div>
<div class="ingredient" id="lettuce">πŸ₯¬</div>
<div class="ingredient" id="cheese">πŸ§€</div>
<div class="ingredient" id="bread">🍞</div>
</div>
<div id="orderBoard">
<div id="order">Order: </div>
<button id="serveButton">Serve</button>
</div>
<div id="scoreBoard">
<p>Score: <span id="score">0</span></p>
<p>Time: <span id="time">60</span> seconds</p>
</div>
</div>
<script src="script.js"></script>
</body>
</html>
74 changes: 74 additions & 0 deletions Games/Cooking_Challenge_Game/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// script.js
const ingredients = document.querySelectorAll('.ingredient');
const orderDisplay = document.getElementById('order');
const serveButton = document.getElementById('serveButton');
const scoreDisplay = document.getElementById('score');
const timeDisplay = document.getElementById('time');

let currentOrder = [];
let selectedIngredients = [];
let score = 0;
let time = 60;

const allIngredients = ['tomato', 'lettuce', 'cheese', 'bread'];

function getRandomIngredient() {
return allIngredients[Math.floor(Math.random() * allIngredients.length)];
}

function generateOrder() {
currentOrder = [];
for (let i = 0; i < 3; i++) {
currentOrder.push(getRandomIngredient());
}
orderDisplay.innerHTML = 'Order: ' + currentOrder.join(', ');
}

ingredients.forEach(ingredient => {
ingredient.addEventListener('click', () => {
if (!selectedIngredients.includes(ingredient.id)) {
selectedIngredients.push(ingredient.id);
ingredient.style.backgroundColor = '#dcdcdc';
}
});
});

serveButton.addEventListener('click', () => {
if (arraysEqual(selectedIngredients, currentOrder)) {
score += 10;
scoreDisplay.innerHTML = score;
resetRound();
} else {
alert('Wrong ingredients!');
}
});

function resetRound() {
selectedIngredients = [];
ingredients.forEach(ingredient => {
ingredient.style.backgroundColor = '#fff';
});
generateOrder();
}

function arraysEqual(a, b) {
if (a.length !== b.length) return false;
a.sort();
b.sort();
for (let i = 0; i < a.length; i++) {
if (a[i] !== b[i]) return false;
}
return true;
}

function updateTimer() {
time--;
timeDisplay.innerHTML = time;
if (time <= 0) {
clearInterval(timer);
alert('Game over! Your score is ' + score);
}
}

generateOrder();
const timer = setInterval(updateTimer, 1000);
51 changes: 51 additions & 0 deletions Games/Cooking_Challenge_Game/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/* styles.css */
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background: #f0f0f0;
margin: 0;
font-family: Arial, sans-serif;
}

#gameContainer {
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
}

#kitchen {
display: flex;
justify-content: center;
gap: 10px;
margin-bottom: 20px;
}

.ingredient {
padding: 20px;
background: #fff;
border: 1px solid #ccc;
cursor: pointer;
font-size: 2rem;
transition: background 0.3s;
}

.ingredient:hover {
background: #f9f9f9;
}

#orderBoard {
margin-bottom: 20px;
}

#serveButton {
padding: 10px;
font-size: 1rem;
cursor: pointer;
}

#scoreBoard p {
margin: 5px 0;
}
20 changes: 8 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ This repository also provides one such platforms where contributers come over an
| Game | Game | Game | Game | Game |



| [Master Typing](https://github.com/kunjgit/GameZone/tree/main/Games/Master_Typing) | [Treasure Hunt](https://github.com/Antiquely3059/GameZone/tree/main/Games/Treasure%20Hunt) | [Virtual Pet](https://github.com/Antiquely3059/GameZone/tree/main/Games/Virtual_Pet) | [MazeRunner](https://github.com/kunjgit/GameZone/tree/main/Games/MazeRunner) | [Ping_Pong_Singleplayer](https://github.com/kunjgit/GameZone/tree/main/Games/Ping_Pong_Singleplayer) | |

| [Tilting Maze](https://github.com/kunjgit/GameZone/tree/main/Games/Tilting_Maze) | [Simon Game Challenge](https://github.com/kunjgit/GameZone/tree/main/Games/Simon_Game_Challenge) | [Snake Game](https://github.com/kunjgit/GameZone/tree/main/Games/Snake_Game) | [Dino Runner Game](https://github.com/kunjgit/GameZone/tree/main/Games/Dino_Runner_Game) |
Expand Down Expand Up @@ -325,19 +324,17 @@ This repository also provides one such platforms where contributers come over an
| [Find_the_ball](https://github.com/kunjgit/GameZone/tree/main/Games/Find_the_ball) |

|[Color The Page](https://github.com/kunjgit/GameZone/tree/main/Games/Color_The_Page)|

|[Pop the Bubbles](https://github.com/kunjgit/GameZone/tree/main/Games/Pop_the_Bubbles)|
[Fidget Spinner Game](https://github.com/kunjgit/GameZone/tree/main/Games/Fidget_Spinner_Game)|
| [Color The Page](https://github.com/kunjgit/GameZone/tree/main/Games/Color_The_Page)|
|[Building Blocks Game](https://github.com/kunjgit/GameZone/tree/main/Games/Building_Block_Game)|
|[Cartoon character guessing game](https://github.com/kunjgit/GameZone/tree/main/Games/Cartoon_Character_Guessing_Game)|

|[Carrom Board Game](https://github.com/kunjgit/GameZone/tree/main/Games/carrom)|
| [Number_Recall_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Number_Recall_Game) |


| [Hit_the_hamster](https://github.com/kunjgit/GameZone/tree/main/Games/Hit_the_hamster) |


|[Carrom Board Game](https://github.com/kunjgit/GameZone/tree/main/Games/carrom)|
| [Number_Recall_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Number_Recall_Game) |
| [Hit_the_hamster](https://github.com/kunjgit/GameZone/tree/main/Games/Hit_the_hamster) |
| [Forest_Guardian](https://github.com/kunjgit/GameZone/tree/main/Games/Forst_Guardian) |
| [Sudoku_light_theme](https://github.com/kunjgit/GameZone/tree/main/Games/Sudoku_light_theme) |
| [Find_the_ball](https://github.com/kunjgit/GameZone/tree/main/Games/Find_the_ball) |
Expand All @@ -362,10 +359,10 @@ This repository also provides one such platforms where contributers come over an
| [Modulo_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Modulo_Game) |
| [Alien_Invasion](https://github.com/kunjgit/GameZone/tree/main/Games/Alien_Invasion) |
| [Drawing_App](https://github.com/kunjgit/GameZone/tree/main/Games/Drawing_app) |

|[Town-Rise](https://github.com/kunjgit/GameZone/tree/main/Games/Town_Rise_Game)|
| [IKnowYou-Mind-Reading-Game](https://github.com/kunjgit/GameZone/tree/main/Games/IKnowYou-Mind-Reading-Game) |
|[Color Swap](https://github.com/kunjgit/GameZone/tree/main/Games/Color_Swap)|
| [Catch_the_falling_Stars](https://github.com/kunjgit/GameZone/tree/main/Games/Catch_the_falling_Stars) |


|[Town-Rise](https://github.com/kunjgit/GameZone/tree/main/Games/Town_Rise_Game)|
| [IKnowYou-Mind-Reading-Game](https://github.com/kunjgit/GameZone/tree/main/Games/IKnowYou-Mind-Reading-Game) |

Expand Down Expand Up @@ -404,6 +401,7 @@ This repository also provides one such platforms where contributers come over an

Terms and conditions for use, reproduction and distribution are under the [Apache-2.0 License](https://opensource.org/license/apache-2-0/).


<!-- mentors -->

<br>
Expand Down Expand Up @@ -543,8 +541,6 @@ This repository also provides one such platforms where contributers come over an

| Game | Game | Game | Game | Game |



| ---------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------- | --- |
| [Master Typing](https://github.com/kunjgit/GameZone/tree/main/Games/Master_Typing) | [Treasure Hunt](https://github.com/Antiquely3059/GameZone/tree/main/Games/Treasure%20Hunt) | [Virtual Pet](https://github.com/Antiquely3059/GameZone/tree/main/Games/Virtual_Pet) | [MazeRunner](https://github.com/kunjgit/GameZone/tree/main/Games/MazeRunner) | [Ping_Pong_Singleplayer](https://github.com/kunjgit/GameZone/tree/main/Games/Ping_Pong_Singleplayer) | |
| [Tilting Maze](https://github.com/kunjgit/GameZone/tree/main/Games/Tilting_Maze) | [Simon Game Challenge](https://github.com/kunjgit/GameZone/tree/main/Games/Simon_Game_Challenge) | [Snake Game](https://github.com/kunjgit/GameZone/tree/main/Games/Snake_Game) | [Dino Runner Game](https://github.com/kunjgit/GameZone/tree/main/Games/Dino_Runner_Game) |
Expand Down
Binary file added assets/images/Cooking_Challenge_Game.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading