Skip to content

Commit

Permalink
Merge pull request #4700 from aditya-bhaumik/catch
Browse files Browse the repository at this point in the history
[New Game] : Catch Craze
  • Loading branch information
kunjgit authored Jul 5, 2024
2 parents ed74745 + 106fd19 commit eabe8cf
Show file tree
Hide file tree
Showing 7 changed files with 366 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Games/Catch_Craze/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# **Game_Name**
Catch Craze

---

<br>

## **Description 📃**
In Catch Craze, you control a basket at the bottom of the screen, aiming to catch falling objects. The game gets progressively harder as you score more points, with objects falling faster and spawning more frequently. The goal is to score as many points as possible before the time runs out.


## **Functionalities 🎮**

1. Click the "Start Game" button to begin.
2. Move the basket to catch the falling objects.
3. Monitor the score and timer.
4. When the timer reaches zero, the game ends, showing your final score and a button to restart the game.

1. Controls: Use the left and right arrow keys to move the basket.
2. Scoring: Each object caught increases your score by 1.
3. Difficulty: Object speed and spawn rate increase every 5 points.
4. Timer: The game lasts for 60 seconds.
5. Game Over: When time runs out, the final score is displayed with an option to play again.

<br>

## **Screenshots 📸**
![Catch_Craze](https://github.com/aditya-bhaumik/GameZone/assets/92214013/48ef4f13-db31-457c-b9bb-6e7611d9255e)
Binary file added Games/Catch_Craze/back1.mp4
Binary file not shown.
34 changes: 34 additions & 0 deletions Games/Catch_Craze/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Catch Craze</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<video autoplay muted loop id="backgroundVideo">
<source src="back1.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
<div id="gameContainer">
<canvas id="gameCanvas"></canvas>
<div id="scoreBoard">Score: 0</div>
<div id="timer">Time: 60</div>
<div id="startScreen">
<h1>Catch Craze</h1>
<button id="startButton">Start Game</button>
</div>
<div id="gameOverScreen">
<h1>Game Over!</h1>
<p id="finalScore"></p>
<button id="reloadButton">Play Again</button>
</div>
</div>
<script src="script.js"></script>
</body>
</html>




145 changes: 145 additions & 0 deletions Games/Catch_Craze/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
const canvas = document.getElementById('gameCanvas');
const ctx = canvas.getContext('2d');
const scoreBoard = document.getElementById('scoreBoard');
const timerElement = document.getElementById('timer');
const startScreen = document.getElementById('startScreen');
const gameOverScreen = document.getElementById('gameOverScreen');
const finalScoreElement = document.getElementById('finalScore');
const startButton = document.getElementById('startButton');
const reloadButton = document.getElementById('reloadButton');

function resizeCanvas() {
canvas.width = canvas.clientWidth;
canvas.height = canvas.clientHeight;
}

resizeCanvas();
window.addEventListener('resize', resizeCanvas);

let score = 0;
let timeLeft = 60;
let keys = {};
let gameInterval;
let timerInterval;
let fallingInterval;

const basket = {
x: canvas.width / 2 - 50,
y: canvas.height - 30,
width: 100,
height: 20,
color: '#e74c3c',
speed: 10
};

const fallingObjects = [];
let objectSize = 20;
let objectSpeed = 3;
let spawnInterval = 1000; // Spawn a new object every 1000 ms

document.addEventListener('keydown', (e) => {
keys[e.key] = true;
});

document.addEventListener('keyup', (e) => {
keys[e.key] = false;
});

function drawBasket() {
ctx.fillStyle = basket.color;
ctx.fillRect(basket.x, basket.y, basket.width, basket.height);
}

function drawFallingObjects() {
ctx.fillStyle = '#f1c40f';
fallingObjects.forEach(obj => {
ctx.fillRect(obj.x, obj.y, objectSize, objectSize);
});
}

function moveBasket() {
if (keys['ArrowLeft'] && basket.x > 0) {
basket.x -= basket.speed;
}
if (keys['ArrowRight'] && basket.x < canvas.width - basket.width) {
basket.x += basket.speed;
}
}

function spawnFallingObject() {
const x = Math.random() * (canvas.width - objectSize);
fallingObjects.push({ x: x, y: 0 });
}

function updateFallingObjects() {
for (let i = fallingObjects.length - 1; i >= 0; i--) {
fallingObjects[i].y += objectSpeed;
if (fallingObjects[i].y > canvas.height) {
fallingObjects.splice(i, 1); // Remove the object if it goes out of canvas
} else if (fallingObjects[i].x > basket.x && fallingObjects[i].x < basket.x + basket.width &&
fallingObjects[i].y + objectSize > basket.y && fallingObjects[i].y < basket.y + basket.height) {
score++;
scoreBoard.innerHTML = 'Score: ' + score;
fallingObjects.splice(i, 1); // Remove the object if it is caught

// Increase difficulty
if (score % 5 === 0) {
objectSpeed += 0.5;
spawnInterval = Math.max(200, spawnInterval - 50);
clearInterval(fallingInterval);
fallingInterval = setInterval(spawnFallingObject, spawnInterval);
}
}
}
}

function updateTime() {
timeLeft--;
timerElement.innerHTML = 'Time: ' + timeLeft;
if (timeLeft <= 0) {
clearInterval(gameInterval);
clearInterval(timerInterval);
clearInterval(fallingInterval);
gameOverScreen.style.display = 'block';
finalScoreElement.innerHTML = 'Your score is ' + score;
}
}

function resetGame() {
score = 0;
timeLeft = 60;
objectSpeed = 3;
spawnInterval = 1000;
scoreBoard.innerHTML = 'Score: ' + score;
timerElement.innerHTML = 'Time: ' + timeLeft;
fallingObjects.length = 0;
basket.x = canvas.width / 2 - 50;
gameOverScreen.style.display = 'none';
}

function startGame() {
resetGame();
gameInterval = setInterval(gameLoop, 20);
timerInterval = setInterval(updateTime, 1000);
fallingInterval = setInterval(spawnFallingObject, spawnInterval);
startScreen.style.display = 'none';
scoreBoard.style.display = 'block';
timerElement.style.display = 'block';
}

function gameLoop() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
drawBasket();
drawFallingObjects();
moveBasket();
updateFallingObjects();
}

startButton.addEventListener('click', () => {
startGame();
});

reloadButton.addEventListener('click', () => {
startGame();
});

106 changes: 106 additions & 0 deletions Games/Catch_Craze/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
body {
margin: 0;
overflow: hidden;
font-family: Arial, sans-serif;
background: #2c3e50; /* Fallback background color */
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
position: relative;
}

#backgroundVideo {
position: absolute;
top: 50%;
left: 50%;
width: 100%;
height: 100%;
object-fit: cover;
transform: translate(-50%, -50%);
z-index: -1; /* Ensure it stays behind other content */
}

#gameContainer {
position: relative;
width: 90%;
max-width: 600px;
height: 80%;
background-color: rgba(39, 174, 96, 0.8); /* Semi-transparent background to see video */
border: 2px solid #34495e;
border-radius: 10px;
overflow: hidden;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
display: flex;
justify-content: center;
align-items: center;
}

canvas {
display: block;
width: 100%;
height: 100%;
}

#scoreBoard, #timer {
position: absolute;
color: white;
font-size: 20px;
display: none; /* Hide initially */
}

#scoreBoard {
top: 10px;
left: 10px;
}

#timer {
top: 10px;
right: 10px;
}

#startScreen, #gameOverScreen {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
color: white;
display: none;
}

#startScreen {
display: block;
}

#gameOverScreen {
display: none;
}

#startButton, #reloadButton {
padding: 10px 20px;
font-size: 20px;
cursor: pointer;
}

@media (max-width: 600px) {
body {
flex-direction: column;
justify-content: flex-start;
}
#gameContainer {
width: 100%;
height: 100%;
border-radius: 0;
}
#scoreBoard, #timer {
font-size: 18px;
}
#startButton, #reloadButton {
font-size: 18px;
padding: 8px 16px;
}
}



53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,59 @@ 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) |
| [Catch_Craze](https://github.com/kunjgit/GameZone/tree/main/Games/Catch_Craze) |

</center>

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

0 comments on commit eabe8cf

Please sign in to comment.