forked from kunjgit/GameZone
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into resolve-readme-conflict
- Loading branch information
Showing
212 changed files
with
6,880 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
Oops, something went wrong.