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

Gravity Switch Game is added #5162

Merged
merged 2 commits into from
Aug 10, 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
21 changes: 21 additions & 0 deletions Games/Gravity_Switch_Game/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# **Gravity_Switch_Game**

## **Description πŸ“ƒ**
Reach the exit (not implemented in this basic version) by navigating through the platforms using gravity switches.

<br>
## **How to play? πŸ•ΉοΈ**
Controls:

- Space bar: Switch gravity direction (up or down)
- No horizontal movement: Focus on vertical movement and gravity switching

Gameplay:

1. Start by falling downwards due to gravity.
2. Switch gravity direction by pressing the space bar when you're close to a platform.
3. Use the switched gravity to move upwards or downwards onto platforms.
4. Continue switching gravity to navigate through the platforms.
5. Reach the top or bottom of the game container to win (not implemented in this basic version).

<br>
14 changes: 14 additions & 0 deletions Games/Gravity_Switch_Game/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<title>Gravity Switch</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="game-container">
<div class="player"></div>
<div class="platforms"></div>
</div>
<script src="script.js"></script>
</body>
</html>
23 changes: 23 additions & 0 deletions Games/Gravity_Switch_Game/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const gameContainer = document.querySelector('.game-container');
const player = document.querySelector('.player');
const platforms = document.querySelector('.platforms');

let gravityDirection = 1;
let playerY = 50;
let playerSpeed = 4;

function movePlayer() {
playerY += playerSpeed * gravityDirection;
player.style.top = `${playerY}px`;
}

function switchGravity() {
gravityDirection *= -1;
}

document.addEventListener('keydown', (event) => {
if (event.keyCode === 32) { // Space bar
switchGravity();
}
});
setInterval(movePlayer, 16);
29 changes: 29 additions & 0 deletions Games/Gravity_Switch_Game/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

.game-container {
width: 800px;
height: 600px;
background-color: #000;
}

.player {
width: 30px;
height: 30px;
background-color: #FFF;
position: absolute;
}

.platforms {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}

.platform {
width: 100px;
height: 20px;
background-color: #666;
margin: 10px;
display: inline-block;
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,7 @@ This repository also provides one such platforms where contributers come over an
| [Pacific Air Battle](https://github.com/kunjgit/GameZone/tree/main/Games/Pacific_Air_Battle) | [Dante](https://github.com/kunjgit/GameZone/tree/main/Games/Dante) | [Ping Pong Multiplayer](https://github.com/kunjgit/GameZone/tree/main/Games/Ping_Pong_Multiplayer) | [Sonic The Hedgehog](https://github.com/kunjgit/GameZone/tree/main/Games/Sonic_The_Hedgehog) | [World Of Emojis](https://github.com/kunjgit/GameZone/tree/main/Games/World_Of_Emojis) |
| [Ball Fall Game](https://github.com/kunjgit/GameZone/tree/main/Games/Ball_Fall_Game) | [Pinball](https://github.com/kunjgit/GameZone/tree/main/Games/Pinball) | [Duck_Hunting_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Duck_Hunting_Game) | [Color Turner](https://github.com/kunjgit/GameZone/tree/main/Games/Color_Turner) | [Catch the Bunny](https://github.com/kunjgit/GameZone/tree/main/Games/Catch_the_Bunny) |
| [Catch me game](https://github.com/kunjgit/GameZone/tree/main/Games/Catch_me_game) | [Blank Detective](https://github.com/kunjgit/GameZone/tree/main/Games/Blanks_Detective) | [Falling Blocks](https://github.com/kunjgit/GameZone/tree/main/Games/Falling_Blocks) | [Movie Guessing Game](https://github.com/kunjgit/GameZone/tree/main/Games/Movie_Guessing_Game) | [Wildcard Bonanza](https://github.com/kunjgit/GameZone/tree/main/Games/Wildcard_Bonanza) |
| [Gravity Switch Game](https://github.com/kunjgit/GameZone/tree/main/Games/Gravity_Switch_Game) |
| [The Last Spartan](https://github.com/kunjgit/GameZone/tree/main/Games/The_Last_Spartan) | [Space Exploration](https://github.com/kunjgit/GameZone/tree/main/Games/Space_Exploration) | [Bow Arrow Game](https://github.com/kunjgit/GameZone/tree/main/Games/Bow_Arrow) | [I Want To Google The Game](https://github.com/kunjgit/GameZone/tree/main/Games/I_Want_To_Google_The_Game) | [Space Gun](https://github.com/kunjgit/GameZone/tree/main/Games/Space_Gun) |
| [Space Huggers](https://github.com/kunjgit/GameZone/tree/main/Games/Space_Huggers) | [Spaceship Escort](https://github.com/kunjgit/GameZone/tree/main/Games/Spaceship_Escort) | [Space Defence](https://github.com/kunjgit/GameZone/tree/main/Games/Space_Defence) | [Glitch Buster](https://github.com/kunjgit/GameZone/tree/main/Games/Glitch_Buster) | [3D Box Game](https://github.com/kunjgit/GameZone/tree/main/Games/3d_Box_Game) |
| [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) |
Expand Down
Binary file added assets/images/Gravity_Switch_Game.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 14 additions & 6 deletions assets/js/gamesData.json
Original file line number Diff line number Diff line change
Expand Up @@ -3223,30 +3223,38 @@
"gameTitle" : "Box In Air Game",
"gameUrl": "Box_In_Air_Game",
"thumbnailUrl": "Box_In_Air_Game.png"

},
"645":{
"gameTitle" : "Block Vault",
"gameUrl": "Block_Vault",
"thumbnailUrl": "Block_Vault.png"
},


"645":{


"646":{
"gameTitle" : "Harry Potter Wizard Quiz",
"gameUrl": "Harry_Potter_Wizard_Quiz/start.html",
"thumbnailUrl": "Harry_Potter_Wizard_Quiz.png"
}

"646":{

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

},
"647":{
},
"648":{
"gameTitle" : "Gravity Switch Game",
"gameUrl": "Gravity_Switch_Game",
"thumbnailUrl": "Gravity_Switch_Game.png"

"649":{
"gameTitle" : "Random Choice Picker",
"gameUrl": "Random_Choice_Picker",
"thumbnailUrl": "Drop_Dash_Game.png"


}
}
Loading