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

[New game]: Flying Fish #5014

Merged
merged 4 commits into from
Jul 30, 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
28 changes: 28 additions & 0 deletions Games/Flying_Fish/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# *Game_Name*
Flying Fish

---

<br>

## *Description 📃*
Flying Fish is an exhilarating game where players guide a fish through airborne obstacles using precise taps. Collect power-ups and avoid hazards to achieve the highest score.

## *Functionalities 🎮*

1. Click the "Start Game" button to begin.
2. Guide the fish through airborne obstacles.
3. Collect power-ups and avoid hazards.
4. Monitor the score and remaining lives.
5. When all lives are lost, the game ends, showing your final score and a button to restart the game.

1. Controls: Use the spacebar to make the fish jump.
2. Scoring: Each power-up collected increases your score by 10 points.
3. Difficulty: As the game progresses, obstacles become more frequent and move faster.
4. Timer: Players start with 3 lives. Hitting an obstacle deducts a life.
5. Game Over: When all lives are lost, the final score is displayed with an option to play again.

<br>

## *Screenshots 📸*
![Flying_Fish](https://github.com/user-attachments/assets/abcd778b-f8c1-4670-ac23-70e6f6373c5f)
19 changes: 19 additions & 0 deletions Games/Flying_Fish/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Flying Fish</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="game-container">
<div id="game">
<div id="fish"></div>
<div id="score">Score: 0</div>
</div>
<button id="startButton">Start Game</button>
</div>
<script src="script.js"></script>
</body>
</html>
85 changes: 85 additions & 0 deletions Games/Flying_Fish/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
const fish = document.getElementById('fish');
const game = document.getElementById('game');
const scoreDisplay = document.getElementById('score');
const startButton = document.getElementById('startButton');

let fishTop = fish.offsetTop;
let fishLeft = fish.offsetLeft;
let gameHeight = game.clientHeight;
let gameWidth = game.clientWidth;
let score = 0;
let gameInterval;
let isGameRunning = false;

startButton.addEventListener('click', startGame);

function startGame() {
isGameRunning = true;
score = 0;
scoreDisplay.textContent = 'Score: ' + score;
fishTop = gameHeight / 2;
fishLeft = 50;
fish.style.top = fishTop + 'px';
fish.style.left = fishLeft + 'px';
startButton.style.display = 'none';
gameInterval = setInterval(gameLoop, 20);
document.addEventListener('keydown', controlFish);
}

function gameLoop() {
if (!isGameRunning) return;

// Gravity
fishTop += 2;
fish.style.top = fishTop + 'px';

// Check for collision with bottom of the game area
if (fishTop > gameHeight - fish.clientHeight) {
endGame();
}

// Increase score
score++;
scoreDisplay.textContent = 'Score: ' + score;
}

function controlFish(event) {
switch (event.code) {
case 'ArrowUp':
fishTop -= 20;
if (fishTop < 0) {
fishTop = 0;
}
fish.style.top = fishTop + 'px';
break;
case 'ArrowDown':
fishTop += 20;
if (fishTop > gameHeight - fish.clientHeight) {
fishTop = gameHeight - fish.clientHeight;
}
fish.style.top = fishTop + 'px';
break;
case 'ArrowLeft':
fishLeft -= 20;
if (fishLeft < 0) {
fishLeft = 0;
}
fish.style.left = fishLeft + 'px';
break;
case 'ArrowRight':
fishLeft += 20;
if (fishLeft > gameWidth - fish.clientWidth) {
fishLeft = gameWidth - fish.clientWidth;
}
fish.style.left = fishLeft + 'px';
break;
}
}

function endGame() {
isGameRunning = false;
clearInterval(gameInterval);
document.removeEventListener('keydown', controlFish);
startButton.textContent = 'Restart Game';
startButton.style.display = 'block';
}
56 changes: 56 additions & 0 deletions Games/Flying_Fish/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
body {
margin: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #000;
color: #0ff;
font-family: 'Courier New', Courier, monospace;
}

.game-container {
text-align: center;
}

#game {
position: relative;
width: 300px;
height: 500px;
border: 2px solid #0ff;
overflow: hidden;
background-color: #111;
}

#fish {
position: absolute;
width: 30px;
height: 30px;
background-color: #0ff;
border-radius: 50%;
top: 50%;
left: 50px;
transform: translateY(-50%);
}

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

#startButton {
margin-top: 20px;
padding: 10px 20px;
background-color: #0ff;
border: none;
color: #000;
font-size: 16px;
cursor: pointer;
border-radius: 5px;
}

#startButton:hover {
background-color: #0aa;
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ This repository also provides one such platforms where contributers come over an
|[Samurai_Fighting_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Samurai_Fighting_Game)| [Tic-tac-toe](https://github.com/kunjgit/GameZone/tree/main/Games/Tic-tac-toe)| [Quest_For_Riches](https://github.com/kunjgit/GameZone/tree/main/Games/Quest_For_Riches)| [Pattern Creation Game](https://github.com/kunjgit/GameZone/tree/main/Games/Pattern_Creation_Game)| [Magic_8_ball_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Magic_8_ball) |
| [Catch_Craze](https://github.com/kunjgit/GameZone/tree/main/Games/Catch_Craze) | [UNO game with computer](https://github.com/kunjgit/GameZone/tree/main/Games/UNO_game_with_Computer) | [Dice_Rolling_Simulator](https://github.com/priyashuu/GameZone/tree/main/Games/Dice_rolling_simulator)| [Space_Dominators](https://github.com/kunjgit/GameZone/tree/main/Games/Space_Dominators)| [Simon_Says](https://github.com/kunjgit/GameZone/tree/main/Games/Simon_Says) |

|[Idle_miner](https://github.com/kunjgit/GameZone/tree/main/Games/Idle_miner)| [Five_Nights_at_Freddys](https://github.com/kunjgit/GameZone/tree/main/Games/Five_Nights_at_Freddys) | [Penalty_Shootout_Game] (https://github.com/kunjgit/GameZone/tree/main/Games/Penalty_Shootout_Game)| | [Circuit_Craze](https://github.com/kunjgit/GameZone/tree/main/Games/Circuit_Craze) |
|[Idle_miner](https://github.com/kunjgit/GameZone/tree/main/Games/Idle_miner)| [Five_Nights_at_Freddys](https://github.com/kunjgit/GameZone/tree/main/Games/Five_Nights_at_Freddys) | [Penalty_Shootout_Game] (https://github.com/kunjgit/GameZone/tree/main/Games/Penalty_Shootout_Game)| | [Circuit_Craze](https://github.com/kunjgit/GameZone/tree/main/Games/Circuit_Craze) | | [Flying_Fish](https://github.com/kunjgit/GameZone/tree/main/Games/Flying_Fish) |

|[Idle_miner](https://github.com/kunjgit/GameZone/tree/main/Games/Idle_miner)| [Five_Nights_at_Freddys](https://github.com/kunjgit/GameZone/tree/main/Games/Five_Nights_at_Freddys) | [Penalty_Shootout_Game] (https://github.com/kunjgit/GameZone/tree/main/Games/Penalty_Shootout_Game)| |[Snake_Gun_Water](https://github.com/kunjgit/GameZone/tree/main/Games/Snake_Gun_Water)|
| [Drum_kit] (https://github.com/kunjgit/GameZone/tree/main/Games/Drum_kit)|
Expand Down
Binary file added assets/images/Flying_Fish.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading