-
Notifications
You must be signed in to change notification settings - Fork 840
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3f4bc44
commit cab1d10
Showing
7 changed files
with
98 additions
and
3 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,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> |
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,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> |
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,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); |
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 @@ | ||
|
||
.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; | ||
} |
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
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