Skip to content

Commit

Permalink
Merge branch 'main' into resolve-readme-conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
ishita-43 authored Jun 21, 2024
2 parents 403a975 + d883bde commit a3caa8d
Show file tree
Hide file tree
Showing 212 changed files with 6,880 additions and 29 deletions.
27 changes: 27 additions & 0 deletions Games/Catch_The_Falling_Object/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Catch the Falling Objects Game

This is a simple browser-based game where you need to catch falling objects using a basket.

## How to Play

1. Open `index.html` in your web browser.
2. Move the basket using your mouse to catch falling objects.
3. If an object reaches the ground without being caught, you'll lose a life.
4. You have 5 lives. If you lose all lives, the game ends.
5. Try to catch as many objects as you can to score points.

## Features

- Catch falling objects with the basket.
- Keep track of your score.
- Monitor your remaining lives.
- Restart the game when it's over.

## Screenshots

![Game Screenshot]GameZone\assets\images\Catch_the_falling_object-1.png

## Credits

This game was created by Nikita Saini [github - @katarianikita2003] as a simple project.

30 changes: 30 additions & 0 deletions Games/Catch_The_Falling_Object/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!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 Objects Game</title>
<link rel="stylesheet" href="style.css">
</head>

<body>
<div class="game-container" id="game-container">
<div class="basket" id="basket"></div>
<div class="score" id="score">Score: 0</div>
<div class="lives" id="lives">
Lives:
<span id="heart-container">
<span class="heart" id="heart1"></span>
<span class="heart" id="heart2"></span>
<span class="heart" id="heart3"></span>
<span class="heart" id="heart4"></span>
<span class="heart" id="heart5"></span>
</span>
</div>
<div class="game-over" id="game-over">Game Over<br>Final Score: <span id="final-score"></span><br><button class="btn" onclick="startGame()">Restart</button></div>
</div>
<script src="script.js"></script>
</body>

</html>
113 changes: 113 additions & 0 deletions Games/Catch_The_Falling_Object/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
const basket = document.getElementById('basket');
const gameContainer = document.getElementById('game-container');
const scoreDisplay = document.getElementById('score');
const livesContainer = document.getElementById('lives');
const gameOverDisplay = document.getElementById('game-over');
const finalScoreDisplay = document.getElementById('final-score');

let score = 0;
let lives = 5;
let fallingObjectInterval;
let gameOver = false;

document.addEventListener('mousemove', (event) => {
if (!gameOver) {
let containerRect = gameContainer.getBoundingClientRect();
let basketWidth = basket.offsetWidth;
let x = event.clientX - containerRect.left - basketWidth / 2;
if (x < 0) x = 0;
if (x > containerRect.width - basketWidth) x = containerRect.width - basketWidth;
basket.style.left = x + 'px';
}
});

function createFallingObject() {
if (gameOver) return;

const fallingObject = document.createElement('div');
fallingObject.classList.add('falling-object');
fallingObject.style.left = Math.random() * (gameContainer.offsetWidth - 30) + 'px';
gameContainer.appendChild(fallingObject);

let fallingInterval = setInterval(() => {
if (gameOver) {
clearInterval(fallingInterval);
return;
}

let top = parseInt(fallingObject.style.top || 0);
if (top > gameContainer.offsetHeight - 40) {
clearInterval(fallingInterval);
fallingObject.remove();
loseLife();
} else {
fallingObject.style.top = top + 5 + 'px';
if (isCaught(fallingObject)) {
clearInterval(fallingInterval);
fallingObject.remove();
score++;
scoreDisplay.innerText = 'Score: ' + score;
}
}
}, 20);
}

function isCaught(fallingObject) {
let objectRect = fallingObject.getBoundingClientRect();
let basketRect = basket.getBoundingClientRect();
return (
objectRect.right >= basketRect.left &&
objectRect.left <= basketRect.right &&
objectRect.bottom >= basketRect.top &&
objectRect.top <= basketRect.bottom
);
}

function loseLife() {
if (lives > 0) {
lives--;
updateLivesDisplay();
}
if (lives <= 0) {
endGame();
}
}

function updateLivesDisplay() {
livesContainer.innerText = 'Lives: ';
for (let i = 1; i <= 5; i++) {
const heart = document.createElement('span');
heart.classList.add('heart');
if (i > lives) {
heart.style.color = 'transparent';
}
heart.innerText = '❤';
livesContainer.appendChild(heart);
}
}

function endGame() {
gameOver = true;
clearInterval(fallingObjectInterval);
finalScoreDisplay.innerText = 'Final Score: ' + score; // Display total score
gameOverDisplay.innerHTML = 'Game Over<br>' + finalScoreDisplay.innerHTML + '<br><button onclick="startGame()">Restart</button>'; // Update game over display with total score and restart button
gameOverDisplay.style.display = 'block';
}

function startGame() {
gameOver = false;
score = 0;
lives = 5;
scoreDisplay.innerText = 'Score: ' + score;
updateLivesDisplay();
gameOverDisplay.style.display = 'none';

// Remove existing falling objects
document.querySelectorAll('.falling-object').forEach(obj => obj.remove());

// Start creating falling objects again
fallingObjectInterval = setInterval(createFallingObject, 1000);
}

// Initialize the game
startGame();
80 changes: 80 additions & 0 deletions Games/Catch_The_Falling_Object/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
body {
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-image: linear-gradient(#e4f37a, #8ded9a);
color: white;
font-family: Arial, sans-serif;
}

.game-container {
position: relative;
width: 700px;
height: 800px;
background-color: #2e2c2c81;
border: 2px solid #3333339f;
overflow: hidden;
}

.basket {
position: absolute;
bottom: 10px;
width: 100px;
height: 30px;
background-color: #33f209;
border-radius: 10px;
}

.falling-object {
position: absolute;
width: 30px;
height: 30px;
background-color: #fff704;
border-radius: 50%;
}

.score,
.lives {
position: absolute;
top: 40px;
font-size: 24px;
}

.heart {
font-size: 24px;
color: rgb(136, 3, 3);
margin-right: 5px;
}

.score {
left: 10px;
}

.lives {
right: 10px;
}

.game-over {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: rgba(0, 0, 0, 0.699);
color: rgb(206, 241, 241);
padding: 25px;
border-radius: 20px;
text-align: center;
display: none;
}

button {
border-radius: 7px;
font-size: medium;
border: 2px solid black;
background-color: #cbe7ff;
margin: 7px 7px;
padding: 4px 22px;
}
2 changes: 1 addition & 1 deletion Games/Cosmic_Blast/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ Cosmic Blast is an exciting and fast-paced arcade game where the fate of Earth l
<!-- Add your screenshots like this -->
<!-- ![image](url) -->

---
---
2 changes: 1 addition & 1 deletion Games/Cosmic_Blast/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ <h2>Earth has been destroyed by the asteroids</h2>
</div>
</div>

<script src="js/script.js"></script>
<script src="script.js"></script>
</body>
</html>
6 changes: 3 additions & 3 deletions Games/Cosmic_Blast/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ document.addEventListener("DOMContentLoaded", function() {
const finalScore = document.getElementById("final-score");

var explosionSound = new Audio();
explosionSound.src = "./assets/explode.mp3";
explosionSound.src = "assets/explode.mp3";
explosionSound.preload = "auto";

let health = 100;
Expand Down Expand Up @@ -75,7 +75,7 @@ document.addEventListener("DOMContentLoaded", function() {
const asteroid = document.createElement("div");
asteroid.className = "asteroid";
const size = Math.floor(Math.random() * 3) + 1; // Random size between 1 and 3
asteroid.style.backgroundImage = `url('/assets/asteroid-${size}.png')`; // Use different asteroid images
asteroid.style.backgroundImage = `url('assets/asteroid-${size}.png')`; // Use different asteroid images
asteroid.setAttribute("size", size); // Store size as an attribute

// Set initial position and angle
Expand Down Expand Up @@ -169,6 +169,6 @@ document.addEventListener("DOMContentLoaded", function() {
if (health <= 0) {
endGame();
}
earth.style.backgroundImage = "url('/assets/earth.png')";
earth.style.backgroundImage = "url('assets/earth.png')";
}
});
8 changes: 4 additions & 4 deletions Games/Cosmic_Blast/style.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
body{
margin: 0;
font-family: Arial, sans-serif;
background-image: url("/assets/background.jpg");
background-image: url("assets/background.jpg");
color: #ffffff;
}

Expand Down Expand Up @@ -84,7 +84,7 @@ body{
position: relative;
width: 100vw;
height: 100vh;
background-image: url("/assets/background.jpg");
background-image: url("assets/background.jpg");
cursor: url('https://raw.githubusercontent.com/coob113/fancy-cursors/master/target1.png') 64 64, auto !important;
}

Expand Down Expand Up @@ -145,7 +145,7 @@ body{
left: 50%;
width: 100%;
height: 100%;
background-image: url("./assets/background.jpg");
background-image: url("assets/background.jpg");
z-index: 10; /* Ensure it's above other elements */
}

Expand All @@ -154,7 +154,7 @@ body{
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-image: url("./assets/ba ckground.jpg");
background-image: url("assets/background.jpg");
padding: 20px;
border-radius: 5px;
text-align: center;
Expand Down
17 changes: 17 additions & 0 deletions Games/Cross_The_River_Game/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<h1 align="center"> Cross_the_river_game</h1>

## **Description 📃*
<p>The farmer is the only one who can pilot the boat. The boat only carries two at a time. The goat can never be left alone with the cabbage, or it will devour it. The wolf also cannot be left alone with the goat, or it will eat it too. Can you cross them all?</p>

## **How to play? 🕹️**
<p>Click on the farmer, wolf, goat or cabbage to enter or leave the boat. Click the boat to cross the river - it'll only do it if the farmer is inside.
<li>The boat can only carry the farmer and one other item at a time.</li>
<li>The farmer cannot leave the wolf alone with the goat.</li>
<li>The farmer cannot leave the goat alone with the cabbage.</li></p>


# Screenshots -
<h3>Beginning of the Game</h3><br>
<img width="527" alt="Screenshot 2024-06-16 at 11 52 36 AM" src="https://github.com/kunjgit/GameZone/assets/142529986/ca4d758d-c8b8-4e00-845b-c1c7f3a048ec">
<img width="1438" alt="Screenshot 2024-06-16 at 11 52 45 AM" src="https://github.com/kunjgit/GameZone/assets/142529986/ab2773ef-12b4-4e1d-bf0b-d1eb9a600de4">
<img width="1440" alt="Screenshot 2024-06-16 at 11 53 16 AM" src="https://github.com/kunjgit/GameZone/assets/142529986/862e99e8-bdbe-4adf-92e2-a1b1188ff493">
8 changes: 8 additions & 0 deletions Games/Cross_The_River_Game/css/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
html, body{
margin: 0;
padding: 0;
}
canvas{
display: block;
image-rendering: auto;
}
Binary file added Games/Cross_The_River_Game/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Cross_The_River_Game/img/boat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Cross_The_River_Game/img/cabbage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Cross_The_River_Game/img/farmer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Cross_The_River_Game/img/goat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Cross_The_River_Game/img/wolf.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions Games/Cross_The_River_Game/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="theme-color" content="#FFF"/>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, user-scalable=no">
<meta name="mobile-web-app-capable" content="yes">
<meta property="og:url" content="https://victorribeiro.com/bridge" />
<meta property="og:type" content="article" />
<meta property="og:title" content="Farmer, wolf, goat, cabbage problem." />
<meta property="og:author" content="Victor Ribeiro" />
<meta property="og:description" content="A JavaScript implementation of the bridge game." />
<meta property="og:image" content="https://victorribeiro.com/bridge/img/farmer.png" />
<meta property="og:image:width" content="512" />
<meta property="og:image:height" content="512" />
<title> Cross the River</title>
<link rel="manifest" href="manifest.json" />
<link rel="stylesheet" href="css/main.css" />
<link rel="icon" href="img/farmer.png" sizes="256x256"/>
<link rel="apple-touch-icon" href="img/farmer.png" />
</head>
<body>

<script src="js/aux.js"></script>
<script src="js/Passenger.js"></script>
<script src="js/Boat.js"></script>
<script src="js/main.js"></script>
</body>
</html>
Loading

0 comments on commit a3caa8d

Please sign in to comment.