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

Added Game #4240

Merged
merged 6 commits into from
Jul 5, 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
25 changes: 25 additions & 0 deletions Games/FruitCatcher/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# **FruitCatcher**

#### Description

"Fruit Catcher" is a simple and engaging game where players control a basket to catch falling fruits. The goal is to catch as many fruits as possible within a limited time, with the game getting progressively harder.

#### Functionality

- The game starts immediately upon loading.
- Players use the left and right arrow keys to move the basket.
- Fruits fall from the top of the screen at increasing speeds.
- Each fruit caught increases the player's score.
- The game ends when a fruit is missed.

#### How to Play

1. **Start the Game:** Open the `index.html` file in a web browser.
2. **Move the Basket:** Use the left (`←`) and right (`β†’`) arrow keys to move the basket.
3. **Catch Fruits:** Position the basket under the falling fruits to catch them.
4. **Score Points:** Each fruit caught increases your score by 1.
5. **End Game:** The game ends when the player decides to stop or refreshes the page. Your final score will be displayed.

Enjoy catching fruits and try to beat your high score!


18 changes: 18 additions & 0 deletions Games/FruitCatcher/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Catch the Falling Stars</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="game">
<div id="basket"></div>
<div id="stars-container"></div>
<div id="score">Score: 0</div>
<div id="game-over">Game Over</div>
</div>
<script src="script.js"></script>
</body>
</html>
85 changes: 85 additions & 0 deletions Games/FruitCatcher/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
const game = document.getElementById('game');
const basket = document.getElementById('basket');
const starsContainer = document.getElementById('stars-container');
const scoreDisplay = document.getElementById('score');
const gameOverDisplay = document.getElementById('game-over');

let score = 0;
let gameInterval;
let starFallInterval;
let starSpeed = 0.1;


document.addEventListener('keydown', moveBasket);

function moveBasket(event) {
const basketRect = basket.getBoundingClientRect();
const gameRect = game.getBoundingClientRect();
const step = 200; // Number of pixels to move per key press

if (event.key === 'ArrowLeft')
{
if (basketRect.left - step > gameRect.left) {
basket.style.left = basket.offsetLeft - step + 'px';
} else{
basket.style.left = (gameRect.left + 10) + 'px';
}
}
if (event.key === 'ArrowRight')
if (basketRect.right + step < gameRect.right){
basket.style.left = basket.offsetLeft + step + 'px';
}
else{
basket.style.left = (gameRect.right - basket.getBoundingClientRect().width - 10) + 'px';
}

}

function createStar() {
const star = document.createElement('div');
star.classList.add('star');
star.style.left = Math.random() * (game.clientWidth - 20) + 'px';
starsContainer.appendChild(star);
}

function fallStars() {
const stars = document.querySelectorAll('.star');
stars.forEach(star => {
const starRect = star.getBoundingClientRect();
if (starRect.top + starSpeed >= game.clientHeight) {
endGame();
} else if (checkCollision(basket, star)) {
star.remove();
score++;
scoreDisplay.textContent = 'Score: ' + score;
} else {
star.style.top = starRect.top - 30 + 'px';
}
});
}

function checkCollision(basket, star) {
const basketRect = basket.getBoundingClientRect();
const starRect = star.getBoundingClientRect();
return !(
basketRect.top > starRect.bottom ||
basketRect.right < starRect.left ||
basketRect.bottom < starRect.top ||
basketRect.left > starRect.right
);
}

function startGame() {
gameInterval = setInterval(fallStars, 10);
creation = setInterval(createStar, 1000 - (score * 10)); //More stars as score goes up
starFallInterval = setInterval(() => { starSpeed ; }, 10);
}

function endGame() {
clearInterval(creation);
clearInterval(gameInterval);
clearInterval(starFallInterval);
gameOverDisplay.style.display = 'block';
}

startGame();
63 changes: 63 additions & 0 deletions Games/FruitCatcher/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
body {
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #282c34;
color: white;
font-family: Arial, sans-serif;
}

#game {
position: relative;
width: 80%;
height: 90vh;
border: 2px solid #fff;
overflow: hidden;
}

#basket {
position: absolute;
bottom: 20px;
left: 50%;
width: 300px;
height: 30px;
background-color: #ffcc00;
border-radius: 10px;
transform: translateX(-50%);
}

#stars-container {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}

.star {
position: absolute;
width: 20px;
height: 20px;
background-color: #fff;
border-radius: 50%;
}

#score {
position: absolute;
top: 10px;
left: 10px;
font-size: 20px;
}

#game-over {
display: none;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 40px;
color: red;
}
53 changes: 1 addition & 52 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ This repository also provides one such platforms where contributers come over an
</center>

| 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 @@ -351,58 +352,6 @@ This repository also provides one such platforms where contributers come over an
|[Turn_on_the_light](https://github.com/kunjgit/GameZone/tree/main/Games/Turn_on_the_light) |
| [Tic-Tac-Toe Game](https://github.com/kunjgit/GameZone/tree/main/Games/Tic-Tac-Toe) |
| [Bubble'z Popper](https://github.com/Chandu6702/GameZone/tree/main/Games/Bubble'z Popper)|
| [Dsa_quiz_game](https://github.com/kunjgit/GameZone/tree/main/Games/Dsa_quiz_game) |
| [Gravity_Simulation_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Gravity_Simulation_Game) |
| [Rapid_click_frenzy](https://github.com/kunjgit/GameZone/tree/main/Games/Rapid_click_frenzy)
| [Catch_The_Ball](https://github.com/kunjgit/GameZone/tree/main/Games/Catch_The_Ball) |
| [Ball_in_Maze](https://github.com/kunjgit/GameZone/tree/main/Games/Ball_in_Maze) |
|[Dsa_quiz_game](https://github.com/kunjgit/GameZone/tree/main/Games/Dsa_quiz_game) |
| [Gravity_Simulation_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Gravity_Simulation_Game)
| [Anagarm-Word-Game](https://github.com/kunjgit/GameZone/tree/main/Games/Anagarm-Word-Game) |
| [Brick Buster Game](https://github.com/kunjgit/GameZone/tree/main/Games/Brick Buster) |
| [SnakeBites](https://github.com/kunjgit/GameZone/tree/main/Games/SnakeBites) |
| [Rapid_click_frenzy](https://github.com/kunjgit/GameZone/tree/main/Games/Rapid_click_frenzy)
| [Alphabet-and-Vowels](https://github.com/kunjgit/GameZone/tree/main/Games/Alphabet-and-Vowels) |
| [Brick Buster Game](https://github.com/kunjgit/GameZone/tree/main/Games/Brick%20Buster) |
| [Penguins Can't Fly](https://github.com/Will2Jacks/GameZoneForked/tree/Task/Games/Penguins_Can't_Fly) |
| [Intellect Quest](https://github.com/Will2Jacks/GameZoneForked/tree/Task/Games/Intellect_Quest) |
| [Number_Guessing_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Number_Guessing_Game) |
| [Currency_Converter](https://github.com/kunjgit/GameZone/tree/main/Games/Currency_Converter) |
| [mario-game](https://github.com/kunjgit/GameZone/tree/main/Games/mario-game) |
| [Fruit_Slicer_Game] (https://github.com/narayani9120/GameZone_B/tree/main/Games/Fruit_Slicer_Game) |
| [Tower_Block_Game](https://github.com/Saipradyumnagoud/GameZone/tree/main/Games/Tower_Block_Game) |
| [Modulo_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Modulo_Game) |
| [Memory_Matching_Game](https://github.com/Saipradyumnagoud/GameZone/tree/main/Games/Memory_Matching_Game) |
|[Penguins Can't Fly](https://github.com/Will2Jacks/GameZoneForked/tree/Task/Games/Penguins_Can't_Fly)|
| [Block_Ninja] (https://github.com/kunjgit/GameZone/tree/main/Games/Block_Ninja) |
| [Shoot_Duck_Game] (https://github.com/kunjgit/GameZone/tree/main/Games/Shoot_Duck_Game) |
| [Disney_Trivia](https://github.com/manmita/GameZone/tree/Disney_Trivia/Games/Disney_Trivia)|
|[puzzle-game](https://github.com/kunjgit/GameZone/tree/main/Games/puzzle-game)|
| [Helicopter_Game](https://github.com/kinjgit/GameZone/tree/main/Games/Helicopter_Game) |
| [Bouncing Ball Game](https://github.com/kunjgit/GameZone/tree/main/Games/Bouncing_Ball_Game) |
|[Harmony_Mixer](https://github.com/kunjgit/GameZone/tree/main/Games/Harmony_Mixer)|
|[Car_Racing_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Car_Racing_Game)|
|[KeySymphony](https://github.com/kunjgit/GameZone/tree/main/Games/KeySymphony)|
|[Math_Race_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Math_Race_Game)|
| [Bunny is Lost](https://github.com/kunjgit/GameZone/tree/main/Games/Bunny_is_Lost)|
|[Steam_Punk](https://github.com/kunjgit/GameZone/tree/main/Games/Steam_Punk)|
|[Tower Defence Game](https://github.com/Will2Jacks/GameZoneForked/tree/Task/Games/Tower_Defence_Game)|
|[Mario Matching Game](https://github.com/ananyag309/GameZone_ggsoc/tree/main/Games/MarioMatchingGame)|
|[Dot_Dash](https://github.com/kunjgit/GameZone/tree/main/Games/Dot_Dash)|
|[Ghost Busting Game](https://github.com/kunjgit/GameZone/tree/main/Games/Ghost_busting_game)|
|[Wheel_of_fortune](https://github.com/Will2Jacks/GameZoneForked/tree/Task/Games/Wheel_of_fortune)|
|[Dot_Box_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Dot_Box_Game)|
| [Cosmic_Blast](https://github.com/kunjgit/GameZone/tree/main/Games/Cosmic_Blast) |
|[Mole](https://github.com/taneeshaa15/GameZone/tree/main/Games/Mole)|
|[Spell Bee](https://github.com/kunjgit/GameZone/tree/main/Games/Spell_Bee)|
| [Go-fish-master](https://github.com/kunjgit/GameZone/tree/main/Games/Go-fish-master) |
|[Pottery-Game](https://github.com/kunjgit/GameZone/tree/main/Games/Pottery-Game)|
| [Ganesh_QR_Maker](https://github.com/kunjgit/GameZone/tree/main/Games/Ganesh_QR_Maker) |
|[Wheel_of_Fortunes](https://github.com/Saipradyumnagoud/GameZone/tree/main/Games/Wheel_of_Fortunes)|
|[Tic-tac-toe](https://github.com/Saipradyumnagoud/GameZone/tree/main/Games/Tic-tac-toe)|
|[Quest_For_Riches](https://github.com/kunjgit/GameZone/tree/main/Games/Quest_For_Riches)|
| [IKnowYou-Mind-Reading-Game](https://github.com/kunjgit/GameZone/tree/main/Games/IKnowYou-Mind-Reading-Game) |
| [Tic_Tac_Toe_Neon](https://github.com/kunjgit/GameZone/tree/main/Games/Tic_Tac_Toe_Neon) |

</center>

Expand Down
Binary file added assets/images/FruitCatcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading