Skip to content

Commit

Permalink
Merge pull request #5146 from Ishitamukherjee2004/main
Browse files Browse the repository at this point in the history
Box In Air Game is added
  • Loading branch information
kunjgit authored Aug 10, 2024
2 parents ccc42cc + 3f4bc44 commit 266ca2e
Show file tree
Hide file tree
Showing 7 changed files with 170 additions and 1 deletion.
23 changes: 23 additions & 0 deletions Games/Box_In_Air_Game/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# **Box_In_Air_Game**

Bow_In_Arrow Game

<br>


## **functionalities 🎮**
<!-- add functionalities over here -->
- Bow_In_Arrow is a game implemented using HTML, CSS, and JavaScript. The game is to shoot monsters and save birds.
<br>

## **How to play? 🕹️**
<!-- add the steps how to play games -->
- Start the game
- Move the man with Arrow Keys
- Shoot arrow with Space Bar
- +1 for hitting monsters
- -5 if monsters reaches birds
- Game Over if score<0
- Monsters speed increases each level.

<br>
22 changes: 22 additions & 0 deletions Games/Box_In_Air_Game/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

<!DOCTYPE html>
<html>
<head>
<title>Table Tennis Game</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="game-container">
<div class="table">
<div class="ball"></div>
<div class="paddle paddle-left"></div>
<div class="paddle paddle-right"></div>
</div>
<div class="scoreboard">
<span id="player1-score">0</span>
<span id="player2-score">0</span>
</div>
</div>
<script src="script.js"></script>
</body>
</html>
63 changes: 63 additions & 0 deletions Games/Box_In_Air_Game/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
let ball = document.querySelector('.ball');
let paddleLeft = document.querySelector('.paddle-left');
let paddleRight = document.querySelector('.paddle-right');
let player1Score = document.querySelector('#player1-score');
let player2Score = document.querySelector('#player2-score');

let ballSpeedX = 4;
let ballSpeedY = 4;
let paddleSpeed = 8;

function moveBall() {
ball.style.top = `${parseInt(ball.style.top) + ballSpeedY}px`;
ball.style.left = `${parseInt(ball.style.left) + ballSpeedX}px`;

if (parseInt(ball.style.top) <= 0 || parseInt(ball.style.top) >= 580) {
ballSpeedY *= -1;
}

if (parseInt(ball.style.left) <= 0 || parseInt(ball.style.left) >= 780) {
ballSpeedX *= -1;
}
if (parseInt(ball.style.left) <= 20 && parseInt(ball.style.top) >= parseInt(paddleLeft.style.top) && parseInt(ball.style.top) <= parseInt(paddleLeft.style.top) + 100) {
ballSpeedX *= -1;
}

if (parseInt(ball.style.left) >= 760 && parseInt(ball.style.top) >= parseInt(paddleRight.style.top) && parseInt(ball.style.top) <= parseInt(paddleRight.style.top) + 100) {
ballSpeedX *= -1;
}
if (parseInt(ball.style.left) <= 0) {
player2Score.textContent = parseInt(player2Score.textContent) + 1;
resetBall();
}

if (parseInt(ball.style.left) >= 780) {
player1Score.textContent = parseInt(player1Score.textContent) + 1;
resetBall();
}
}
function movePaddles(event) {
if (event.key === 'w') {
paddleLeft.style.top = `${parseInt(paddleLeft.style.top) - paddleSpeed}px`;
}

if (event.key === 's') {
paddleLeft.style.top = `${parseInt(paddleLeft.style.top) + paddleSpeed}px`;
}
if (event.key === 'ArrowUp') {
paddleRight.style.top = `${parseInt(paddleRight.style.top) - paddleSpeed}px`;
}

if (event.key === 'ArrowDown') {
paddleRight.style.top = `${parseInt(paddleRight.style.top) + paddleSpeed}px`;
}
}
function resetBall() {
ball.style.top = '50%';
ball.style.left = '50%';
ballSpeedX = 4;
ballSpeedY = 4;
}

document.addEventListener('keydown', movePaddles);
setInterval(moveBall, 16);
48 changes: 48 additions & 0 deletions Games/Box_In_Air_Game/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
.game-container {
width: 800px;
height: 600px;
margin: 40px auto;
background-color: #f0f0f0;
}

.table {
width: 100%;
height: 100%;
position: relative;
background-color: #008000;
}

.ball {
width: 20px;
height: 20px;
background-color: #fff;
border-radius: 50%;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.paddle {
width: 10px;
height: 100px;
background-color: #fff;
position: absolute;
top: 50%;
transform: translate(0, -50%);
}

.paddle-left {
left: 10px;
}

.paddle-right {
right: 10px;
}
.scoreboard {
position: absolute;
top: 10px;
left: 50%;
transform: translate(-50%, 0);
font-size: 24px;
font-weight: bold;
}
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,8 @@ This repository also provides one such platforms where contributers come over an
| [Escape](https://github.com/kunjgit/GameZone/tree/main/Games/Escape) | [Retro Dungeon Puzzle](https://github.com/kunjgit/GameZone/tree/main/Games/Retro_Dungeon_Puzzle) | [Immunity Collapse](https://github.com/kunjgit/GameZone/tree/main/Games/Immunity_Collapse) | [Hunt Your Card](https://github.com/kunjgit/GameZone/tree/main/Games/Hunt_Your_Card) | [Tenacity](https://github.com/kunjgit/GameZone/tree/main/Games/Tenacity) |
| [Emoji Puzzle Game](https://github.com/kunjgit/GameZone/tree/main/Games/Emoji_Puzzle_Game) | [Back To Space](https://github.com/kunjgit/GameZone/tree/main/Games/Back_To_Space) | [Snooze](https://github.com/kunjgit/GameZone/tree/main/Games/Snooze) | [Galaxy Rider](https://github.com/kunjgit/GameZone/tree/main/Games/Galaxy_Rider) | [Squared Lines](https://github.com/kunjgit/GameZone/tree/main/Games/Squared_Lines) |
| [Space War](https://github.com/kunjgit/GameZone/tree/main/Games/Space_War) | [Sciara of Colors](https://github.com/kunjgit/GameZone/tree/main/Games/Sciara_Of_Colors) | [JunoJs](https://github.com/kunjgit/GameZone/tree/main/Games/JunoJs) | [Fall Down](https://github.com/kunjgit/GameZone/tree/main/Games/Fall_Down) | [Cat Goric](https://github.com/kunjgit/GameZone/tree/main/Games/Cat_Goric) |
| [Cable Maze](https://github.com/kunjgit/GameZone/tree/main/Games/Cable_Maze) | [Spaceducts](https://github.com/kunjgit/GameZone/tree/main/Games/Spaceducts) | [Zurbo](https://github.com/kunjgit/GameZone/tree/main/Games/Zurbo) | [Blast Zone](https://github.com/kunjgit/GameZone/tree/main/Games/BlastZone) | [Free Bird](https://github.com/kunjgit/GameZone/tree/main/Games/Free_Bird) |
| [Cable Maze](https://github.com/kunjgit/GameZone/tree/main/Games/Cable_Maze) | [Spaceducts](https://github.com/kunjgit/GameZone/tree/main/Games/Spaceducts)
| [Box In Air Game](https://github.com/kunjgit/GameZone/tree/main/Games/Box_In_Air_Game) | [Zurbo](https://github.com/kunjgit/GameZone/tree/main/Games/Zurbo) | [Blast Zone](https://github.com/kunjgit/GameZone/tree/main/Games/BlastZone) | [Free Bird](https://github.com/kunjgit/GameZone/tree/main/Games/Free_Bird) |
| [Maximise Boxes](https://github.com/kunjgit/GameZone/tree/main/Games/MaximiseBoxes) | [Slide Puzzle](https://github.com/kunjgit/GameZone/tree/main/Games/Slide_Puzzle) | [Diamond Run](https://github.com/kunjgit/GameZone/tree/main/Games/Diamond_Run) | [Everyones Sky](https://github.com/kunjgit/GameZone/tree/main/Games/Everyones_Sky) | [Line Of Fire](https://github.com/kunjgit/GameZone/tree/main/Games/Line_Of_Fire) |
| [1024 Moves](https://github.com/kunjgit/GameZone/tree/main/Games/1024_Moves) | [Save The Forest](https://github.com/kunjgit/GameZone/tree/main/Games/Save_The_Forest) | [Dragon World Game](https://github.com/kunjgit/GameZone/tree/main/Games/Dragon_World_Game) | [DuckHunt](https://github.com/kunjgit/GameZone/tree/main/Games/DuckHunt) | [Plankman](https://github.com/kunjgit/GameZone/tree/main/Games/Plankman) |
| [Hold The Cloud](https://github.com/kunjgit/GameZone/tree/main/Games/Hold_The_Cloud) | [Labyrinth](https://github.com/kunjgit/GameZone/tree/main/Games/Labyrinth) | [RIP](https://github.com/kunjgit/GameZone/tree/main/Games/RIP) | [Risky Nav](https://github.com/kunjgit/GameZone/tree/main/Games/Risky_Nav) | [Pixels From Space](https://github.com/kunjgit/GameZone/tree/main/Games/Pixels_From_Space) |
Expand Down
Binary file added assets/images/Box_In_Air_Game.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions assets/js/gamesData.json
Original file line number Diff line number Diff line change
Expand Up @@ -3213,6 +3213,17 @@
"thumbnailUrl": "Sky_Lift_Dash.png"
},
"643":{

"gameTitle" : "Droop Dash Game",
"gameUrl": "Drop_Dash_Game",
"thumbnailUrl": "Drop_Dash_Game.png"
},

"644":{
"gameTitle" : "Box In Air Game",
"gameUrl": "Box_In_Air_Game",
"thumbnailUrl": "Box_In_Air_Game.png"

"gameTitle" : "Block Vault",
"gameUrl": "Block_Vault",
"thumbnailUrl": "Block_Vault.png"
Expand All @@ -3226,5 +3237,6 @@
"gameTitle" : "Droop Dash Game",
"gameUrl": "Drop_Dash_Game",
"thumbnailUrl": "Drop_Dash_Game.png"

}
}

0 comments on commit 266ca2e

Please sign in to comment.