Skip to content

Commit

Permalink
Bash_Mole_Gameis added
Browse files Browse the repository at this point in the history
  • Loading branch information
pallasivasai committed Aug 8, 2024
1 parent 04babeb commit 317b9cd
Show file tree
Hide file tree
Showing 7 changed files with 200 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ ________________________________________________________________________________
| 206 | [Bomber_Game](.SinglePlayer%20-%20Games/Bomber_Game) |
| 207 | [Shape_Clicker_Game](.SinglePlayer%20-%20Games/Shape_Clicker_Game) |
| 208 | [Brick_Breaker_Game](.SinglePlayer%20-%20Games/Brick_Breaker_Game) |
| 209 | [Bash_Mole_Game](.SinglePlayer%20-%20Games/Bash_Mole_Game) |

</div>

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions SinglePlayer - Games/Bash_Mole_Game/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Bash Mole Game

This is a simple **Bash Mole Game** built using HTML, CSS, and JavaScript. The objective of the game is to click (bash) on the moles that pop up from the holes to earn points.

## How to Play

- The game lasts for 10 seconds.
- Moles will randomly pop up from the holes.
- Click on the moles to increase your score.
- Your score is displayed at the top of the page.

## Files

- `index.html`: The main HTML file that sets up the game structure.
- `style.css`: The CSS file for styling the game interface.
- `script.js`: The JavaScript file containing the game logic.

## How to Run

1. Clone or download this repository.
2. Open `index.html` in your web browser.

## Future Enhancements

- Add different levels with increasing difficulty.
- Implement a high-score tracking system.
- Add sound effects and animations for better gameplay experience.

## License

This project is open-source and available under the MIT License.
25 changes: 25 additions & 0 deletions SinglePlayer - Games/Bash_Mole_Game/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bash Mole Game</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>Bash Mole Game</h1>
<p id="score">Score: 0</p>
<div class="grid">
<div class="hole" id="hole1"></div>
<div class="hole" id="hole2"></div>
<div class="hole" id="hole3"></div>
<div class="hole" id="hole4"></div>
<div class="hole" id="hole5"></div>
<div class="hole" id="hole6"></div>
<div class="hole" id="hole7"></div>
<div class="hole" id="hole8"></div>
<div class="hole" id="hole9"></div>
</div>
<script src="script.js"></script>
</body>
</html>
49 changes: 49 additions & 0 deletions SinglePlayer - Games/Bash_Mole_Game/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
const holes = document.querySelectorAll('.hole');
const scoreDisplay = document.getElementById('score');
let score = 0;
let lastHole;
let timeUp = false;

function randomTime(min, max) {
return Math.round(Math.random() * (max - min) + min);
}

function randomHole(holes) {
const index = Math.floor(Math.random() * holes.length);
const hole = holes[index];
if (hole === lastHole) {
return randomHole(holes);
}
lastHole = hole;
return hole;
}

function peep() {
const time = randomTime(200, 1000);
const hole = randomHole(holes);
hole.classList.add('mole');
setTimeout(() => {
hole.classList.remove('mole');
if (!timeUp) peep();
}, time);
}

function startGame() {
scoreDisplay.textContent = 'Score: 0';
score = 0;
timeUp = false;
peep();
setTimeout(() => timeUp = true, 10000); // 10 seconds game
}

function whack(e) {
if (!e.isTrusted) return; // Prevent cheating
if (e.target.classList.contains('mole')) {
score++;
e.target.classList.remove('mole');
scoreDisplay.textContent = 'Score: ' + score;
}
}

holes.forEach(hole => hole.addEventListener('click', whack));
startGame();
38 changes: 38 additions & 0 deletions SinglePlayer - Games/Bash_Mole_Game/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
body {
text-align: center;
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 0;
}

h1 {
margin-top: 20px;
font-size: 2.5rem;
color: #333;
}

#score {
font-size: 1.5rem;
margin: 10px 0;
}

.grid {
display: grid;
grid-template-columns: repeat(3, 150px);
grid-gap: 10px;
justify-content: center;
margin-top: 20px;
}

.hole {
width: 150px;
height: 150px;
background-color: #8c8c8c;
border-radius: 10px;
position: relative;
}

.hole.mole {
background-color: #ff6347;
}
56 changes: 56 additions & 0 deletions additionalpage/game.html
Original file line number Diff line number Diff line change
Expand Up @@ -7838,6 +7838,62 @@ <h4 class = "text-white uppercase game-card-title">Brick_Breaker_Game</h4>



<!--Card start-->
<div class = "game-card">
<div class = "game-card-top img-fit-cover">
<video src="https://drive.google.com/file/d/1go-TqejXqDAXSzhQ5YTryId9JWWO2AUf/view?usp=drive_link" link " type="video/mp4" muted loop class="clip" ></video>
<img src = "../SinglePlayer - Games/Banner - images/Bash_Mole_Game.png" alt = "">
<div class = "ratings-count">
45
<img src = "../SinglePlayer - Games/Banner - images/Bash_Mole_Game.png" alt = "" class = "ms-2">
</div>
</div>
<div class = "game-card-bottom">
<div class="share-icon text-2xl" onclick="copyLink(this)">
<i class="fas fa-share-alt"></i>
<input type="hidden"
value="https://gamesphere-multiplayer.github.io/GameSphere/SinglePlayer%20-%20Games/Bash_Mole_Game/index.html" />
<!--If there are spaces in your naming of folder, put %20 in between, ex:
link%20to%20the%html%file%20for%your&game-->

<!--The share link will be active only when it is deployed over website-->
</div>

<div class = "flex flex-col sm:flex-row justify-between items-start flex-wrap">
<div class = "py-1">
<h4 class = "text-white uppercase game-card-title">Bash_Mole_Game</h4>
<p class = "para-text">Bash_Mole_Game</p>
</div>
<div class = "star-rating mt-2 sm:mt-0 py-1">
<img src = "../assets/icons/star-green.svg">
<img src = "../assets/icons/star-green.svg">
<img src = "../assets/icons/star-green.svg">
<img src = "../assets/icons/star-green.svg">
<img src = "../assets/icons/star-green-half.svg">
</div>
</div>
<div class = "block-wrap flex justify-between items-end">
<div class = "details-group">
<div class = "flex items-center">
<p class = "font-semibold">Release Date: &nbsp;</p>
<p>20.06.2023</p>
</div>
<div class = "flex items-center">
<p class = "font-semibold">Updated: &nbsp;</p>
<p>Action | Desktop</p>
</div>
</div>
<div class = "flex flex-col items-end justify-between">
<a target="_blank" href = "../SinglePlayer - Games/Bash_Mole_Game/index.html" class = "btn-primary uppercase">Play Now</a>
</div>
</div>
</div>
</div>
<!--Card end-->






<!--Card start-->
Expand Down

0 comments on commit 317b9cd

Please sign in to comment.