Skip to content

Commit

Permalink
Gravity Switch Game is added
Browse files Browse the repository at this point in the history
  • Loading branch information
Ishitamukherjee2004 authored Aug 10, 2024
1 parent 3f4bc44 commit cab1d10
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 3 deletions.
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 @@ -592,6 +592,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.
13 changes: 10 additions & 3 deletions assets/js/gamesData.json
Original file line number Diff line number Diff line change
Expand Up @@ -3223,15 +3223,22 @@
"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"
}
"643":{
},
"646":{
"gameTitle" : "Droop Dash Game",
"gameUrl": "Drop_Dash_Game",
"thumbnailUrl": "Drop_Dash_Game.png"

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

}
}

0 comments on commit cab1d10

Please sign in to comment.