Skip to content

Commit

Permalink
Merge pull request #4554 from mukilan2815/main
Browse files Browse the repository at this point in the history
Ant Smasher game
  • Loading branch information
kunjgit authored Jul 5, 2024
2 parents 5003531 + 9820fd6 commit 671a572
Show file tree
Hide file tree
Showing 8 changed files with 231 additions and 15 deletions.
20 changes: 20 additions & 0 deletions Games/Ant_Smasher/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# **Game_Name**

Ant Smasher

## **Description 📃**

Frontend game developed using HTML, CSS, JavaScript. Player has to kill all the Ants

## **functionalities 🎮**

- Player has to kill all the Ants by Smashing it.

## **How to play? 🕹️**

- Click the Start button to start the game
- When players hits the ant the score will get increased.

## **Screenshots 📸**

![alt text](./img/image.png)
37 changes: 37 additions & 0 deletions Games/Ant_Smasher/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Ant Smasher Game</title>
<link href='https://fonts.googleapis.com/css?family=Amatic+SC:400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="style.css">
</head>
<body>

<h1>Ant Smasher<span class="score">0</span></h1>
<button onClick="startGame()" style="float:right;">Start</button>

<div class="game">
<div class="hole hole1">
<div class="mole"></div>
</div>
<div class="hole hole2">
<div class="mole"></div>
</div>
<div class="hole hole3">
<div class="mole"></div>
</div>
<div class="hole hole4">
<div class="mole"></div>
</div>
<div class="hole hole5">
<div class="mole"></div>
</div>
<div class="hole hole6">
<div class="mole"></div>
</div>
</div>

<script src="script.js"></script>
</body>
</html>
47 changes: 47 additions & 0 deletions Games/Ant_Smasher/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
const holes = document.querySelectorAll(".hole");
const scoreBoard = document.querySelector(".score");
const moles = document.querySelectorAll(".mole");
let lastHole;
let timeUp = false;
let score = 0;

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

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

function peep() {
const time = randomTime(500, 2000);
const hole = randomHole(holes);
hole.classList.add("up");
setTimeout(() => {
hole.classList.remove("up");
if (!timeUp) peep();
}, time);
}

function startGame() {
scoreBoard.textContent = 0;
timeUp = false;
score = 0;
peep();
setTimeout(() => (timeUp = true), 10000);
}

function bonk(e) {
if (!e.isTrusted) return; // cheater!
score++;
this.parentNode.classList.remove("up");
scoreBoard.textContent = score;
}

moles.forEach((mole) => mole.addEventListener("click", bonk));
72 changes: 72 additions & 0 deletions Games/Ant_Smasher/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
html {
box-sizing: border-box;
font-size: 10px;
background: #9b7653;
}

*,
*:before,
*:after {
box-sizing: inherit;
}

body {
padding: 0;
margin: 0;
font-family: "Amatic SC", cursive;
}

h1 {
text-align: center;
font-size: 10rem;
line-height: 1;
margin-bottom: 0;
}

.score {
background: rgba(255, 255, 255, 0.2);
padding: 0 3rem;
line-height: 1;
border-radius: 1rem;
}

.game {
width: 600px;
height: 400px;
display: flex;
flex-wrap: wrap;
margin: 0 auto;
}

.hole {
flex: 1 0 33.33%;
overflow: hidden;
position: relative;
}

.hole:after {
display: block;
background: url(../../assets/images/Ant_Smasher_dirt.svg) bottom center
no-repeat;
background-size: contain;
content: "";
width: 100%;
height: 70px;
position: absolute;
z-index: 2;
bottom: -30px;
}

.mole {
background: url("../../assets/images/Ant_Smasher.png") bottom center no-repeat;
background-size: 60%;
position: absolute;
top: 100%;
width: 100%;
height: 100%;
transition: all 0.4s;
}

.hole.up .mole {
top: 0;
}
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ This repository also provides one such platforms where contributers come over an
| [Mastermind_Mania](https://github.com/kunjgit/GameZone/tree/main/Games/Mastermind_Mania) | [Ludo_4_Player](https://github.com/kunjgit/GameZone/tree/main/Games/Ludo_4_Player) | [AirBalloon](https://github.com/kunjgit/GameZone/tree/main/Games/AirBalloon) | [Space Invaders](https://github.com/kunjgit/GameZone/tree/main/Games/Space_Invaders) | [Cut the Rope](https://github.com/kunjgit/GameZone/tree/main/Games/Cut_the_rope) |
| [Caesar&Cipher](https://github.com/kunjgit/GameZone/tree/main/Games/Caesar_Cipher) | [Monster_Maker](https://github.com/kunjgit/GameZone/tree/main/Games/Monster_Maker) | [Stolen Sword](https://github.com/kunjgit/GameZone/tree/main/Games/Stolen_Sword) | [Mastermind](https://github.com/kunjgit/GameZone/tree/main/Games/Mastermind) | [Highway 404](https://github.com/kunjgit/GameZone/tree/main/Games/Highway_404) |
| [BullseyeGame](https://github.com/kunjgit/GameZone/tree/main/Games/BullseyeGame) | [Crossword Game](https://github.com/kunjgit/GameZone/tree/main/Games/Crossword_Game) | [Guess the Correct Logo](https://github.com/shruti-2412/GameZone/tree/main/Games/Guess_The_Correct_Logo) | [Painting_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Painting_Game) | [Platform_game_engine](https://github.com/kunjgit/GameZone/tree/main/Games/Platform_game_engine) |
| [Kill_The_Bird](https://github.com/kunjgit/GameZone/tree/main/Games/Kill_The_Bird) |
| [Kill_The_Bird](https://github.com/kunjgit/GameZone/tree/main/Games/Kill_The_Bird) |
| [Doppelkopf](https://github.com/kunjgit/GameZone/tree/main/Games/Doppelkopf) | [quiz_game](https://github.com/kunjgit/GameZone/tree/main/Games/quiz_game) | [Island Survival](https://github.com/kunjgit/GameZone/tree/main/Games/Island_Survival) | [Linkup Game](https://github.com/kunjgit/GameZone/tree/main/Games/linkup) | [Trivia_Card](https://github.com/kunjgit/GameZone/tree/main/Games/Trivia_Card) |
| [Insect Catch Game](https://github.com/kunjgit/GameZone/tree/main/Games/Insect_Catch_Game) | [Carnival_game](https://github.com/kunjgit/GameZone/tree/main/Games/Carnival_game) | [Make Me Laugh](https://github.com/kunjgit/GameZone/tree/main/Games/Make_Me_Laugh) | [Avoider_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Avoider_Game) | [Dungeon_Crawler](https://github.com/kunjgit/GameZone/tree/main/Games/Dungeon_Crawler) |
| [snake_water_gun](https://github.com/kunjgit/GameZone/tree/main/Games/snake_water_gun) | [Run and Jump](https://github.com/kunjgit/GameZone/tree/main/Games/Run_and_Jump) | [AI CHESS Game](https://github.com/kunjgit/GameZone/tree/main/Games/AI_CHESS_Game) | [Fruit_Catching](https://github.com/kunjgit/GameZone/tree/main/Games/Fruit_Catching) | [Bulls eye](https://github.com/kunjgit/GameZone/tree/main/Games/Bulls_eye) |
Expand Down Expand Up @@ -626,22 +626,22 @@ This repository also provides one such platforms where contributers come over an
| [CSS Select](https://github.com/kunjgit/GameZone/tree/main/Games/CSS_Select) | [Squid](https://github.com/kunjgit/GameZone/tree/main/Games/Squid_Game) | [Flip Coin](https://github.com/kunjgit/GameZone/tree/main/Games/Flip_Coin) | [Witty Word Quest](https://github.com/kunjgit/GameZone/tree/main/Games/witty_word_quest) | [Typing Game](https://github.com/Ishan-77/GameZone/tree/main/Games/Typing_Game) |
| [numeral-whiz](https://github.com/Ishan-77/GameZone/tree/main/Games/numeral-whiz) | [candy_match](https://github.com/kunjgit/GameZone/tree/main/Games/Candy_Match_Saga) | [Crossy_Road](https://github.com/tanujbordikar/GameZone/tree/Crossy_Road) | [HueHero](https://github.com/kunjgit/GameZone/tree/main/Games/HueHero) | [Puzzel_Winner](https://github.com/kunjgit/GameZone/tree/main/Games/Puzzel_Winner) |
| [Emoji_Intruder](https://github.com/kunjgit/GameZone/tree/main/Games/Emoji_Intruder) | [Guess The Weapon](https://github.com/kunjgit/GameZone/tree/main/Games/Guess_The_Weapon) | [Guess Who](https://github.com/kunjgit/GameZone/tree/main/Games/Guess_Who) | [Pop My Balloon](https://github.com/kunjgit/GameZone/tree/main/Games/Pop_My_Balloon) | [Color_Blast](https://github.com/kunjgit/GameZone/tree/main/Games/Color_Blast) |
| [Maze_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Maze_Game) | [Coloron](https://github.com/kunjgit/GameZone/tree/main/Games/Coloron).
| [Wordling](https://github.com/kunjgit/GameZone/tree/main/Games/Wordling)
| [HTML5_Controller_Tester](https://github.com/kunjgit/GameZone/tree/main/Games/HTML5_Controller_Tester)
| [Maze_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Maze_Game) | [Coloron](https://github.com/kunjgit/GameZone/tree/main/Games/Coloron). | [Spirograph](https://github.com/kunjgit/GameZone/tree/main/Games/Spirograph) |
| [Black_jackk](https://github.com/kunjgit/GameZone/tree/main/Games/Black_jackk) | [Audio_Wordle](https://github.com/kunjgit/GameZone/tree/main/Games/Audio_Wordle)
| [Black_jackk](https://github.com/kunjgit/GameZone/tree/main/Games/Black_jackk) | [Audio_Wordle](https://github.com/kunjgit/GameZone/tree/main/Games/Audio_Wordle>>>>>>> main
| [Earth_Guardian](https://github.com/kunjgit/GameZone/tree/main/Games/Earth_Guardian) |
| [escaperoom](https://github.com/kunjgit/GameZone/tree/main/Games/escaperoom)
| [Ball_Shooting_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Ball_Shooting_Game) | [HTML5_Controller_Tester](https://github.com/kunjgit/GameZone/tree/main/Games/HTML5_Controller_Tester)
| [numeral-whiz](https://github.com/Ishan-77/GameZone/tree/main/Games/numeral-whiz) | [candy_match](https://github.com/kunjgit/GameZone/tree/main/Games/Candy_Match_Saga) | [Crossy_Road](https://github.com/tanujbordikar/GameZone/tree/Crossy_Road) | [HueHero](https://github.com/kunjgit/GameZone/tree/main/Games/HueHero) | [Puzzel_Winner](https://github.com/kunjgit/GameZone/tree/main/Games/Puzzel_Winner) |
| [Tower Stack](https://github.com/kunjgit/GameZone/tree/main/Games/Tower_Stack) |
| [Maze_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Maze_Game) | [TriHand_Tactics](https://github.com/kunjgit/GameZone/tree/main/Games/TriHand_Tactics) | [Earth_Guardian](https://github.com/kunjgit/GameZone/tree/main/Games/Earth_Guardian) | [Ball_Shooting_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Ball_Shooting_Game) |
| [Ball_Shooting_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Ball_Shooting_Game) | [CatchTheBall](https://github.com/kunjgit/GameZone/tree/main/Games/CatchTheBall) |
| [CopyCat](https://github.com/kunjgit/GameZone/tree/main/Games/CopyCat) |
| [CopyCat](https://github.com/kunjgit/GameZone/tree/main/Games/CopyCat) |
| [Cross_The_River_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Cross_The_River_Game) |
[DoraemonRun ](https://github.com/kunjgit/GameZone/tree/main/Games/DoraemonRun) |
| [Memory_Cards_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Memory_Cards_Game) |
| [Typing_Speed_Test2](https://github.com/kunjgit/GameZone/tree/main/Games/Typing_Speed_Test2) | [Tic Tac Toe Responsive ](https://github.com/kunjgit/GameZone/tree/main/Games/Tic_tac_toe_responsive) | [Minesweeper Easy ](https://github.com/kunjgit/GameZone/tree/main/Games/MineSweeper_Easy) |
| [Typing_Speed_Test2](https://github.com/kunjgit/GameZone/tree/main/Games/Typing_Speed_Test2) | [Tic Tac Toe Responsive ](https://github.com/kunjgit/GameZone/tree/main/Games/Tic_tac_toe_responsive) | [Minesweeper Easy ](https://github.com/kunjgit/GameZone/tree/main/Games/MineSweeper_Easy) |
| [Technical_Mind_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Technical_Mind_Game) |
[Slide_Master_Puzzle](https://github.com/kunjgit/GameZone/tree/Main/Games/Slide_Master_Puzz)| |
| [Ball_Shooting_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Ball_Shooting_Game) | [Letter_Sleuth](https://github.com/swetha5157/GameZone/tree/main/Games/Letter_Sleuth)
Expand Down Expand Up @@ -773,32 +773,32 @@ This repository also provides one such platforms where contributers come over an
| [Sudoku_light_theme](https://github.com/kunjgit/GameZone/tree/main/Games/Sudoku_light_theme) |
| [Find_the_ball](https://github.com/kunjgit/GameZone/tree/main/Games/Find_the_ball) |
|[Color The Page](https://github.com/kunjgit/GameZone/tree/main/Games/Color_The_Page)|
|[Lunar Lander](https://github.com/kunjgit/GameZone/tree/main/Games/Lunar_Lander)|
|[AquaSort_Game](https://github.com/kunjgit/GameZone/tree/main/Games/AquaSort_Game) |
|[Chess_Game_computer](https://github.com/kunjgit/GameZone/tree/main/Games/Chess_Game_computer) |
|[Turn_on_the_light](https://github.com/kunjgit/GameZone/tree/main/Games/Turn_on_the_light) |
|[AquaSort_Game](https://github.com/kunjgit/GameZone/tree/main/Games/AquaSort_Game) |
| [Snake](https://github.com/kunjgit/GameZone/tree/main/Games/snake)                |
| [whack a mole](https://github.com/kunjgit/GameZone/tree/main/Games/whack%20a%20mole) |
|[AquaSort_Game](https://github.com/kunjgit/GameZone/tree/main/Games/AquaSort_Game) |
| [Snake](https://github.com/kunjgit/GameZone/tree/main/Games/snake)                |
| [Dice_Game] (https://github.com/shivan2004/GameZone/tree/main/Games/Dice_Game)|
|[HitOrMiss](https://github.com/kunjgit/GameZone/tree/main/Games/HitOrMiss)|
|[Lunar Lander](https://github.com/kunjgit/GameZone/tree/main/Games/Lunar_Lander)|
|[AquaSort_Game](https://github.com/kunjgit/GameZone/tree/main/Games/AquaSort_Game) |
| [Snake](https://github.com/kunjgit/GameZone/tree/main/Games/snake)                |
| [Tetris Game](https://github.com/kunjgit/GameZone/tree/main/Games/tetris_game)|
|[Chess_Game_computer](https://github.com/kunjgit/GameZone/tree/main/Games/Chess_Game_computer) |
|[Turn_on_the_light](https://github.com/kunjgit/GameZone/tree/main/Games/Turn_on_the_light) |
| [Tic-Tac-Toe Game](https://github.com/kunjgit/GameZone/tree/main/Games/Tic-Tac-Toe) |
| [Bubble'z Popper](https://github.com/Chandu6702/GameZone/tree/main/Games/Bubble'z Popper)|
| [Dsa_quiz_game](https://github.com/kunjgit/GameZone/tree/main/Games/Dsa_quiz_game) |
| [Gravity_Simulation_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Gravity_Simulation_Game) |

| [Rapid_click_frenzy](https://github.com/kunjgit/GameZone/tree/main/Games/Rapid_click_frenzy)
| [Catch_The_Ball](https://github.com/kunjgit/GameZone/tree/main/Games/Catch_The_Ball) |
| [Ball_in_Maze](https://github.com/kunjgit/GameZone/tree/main/Games/Ball_in_Maze) |
|[Dsa_quiz_game](https://github.com/kunjgit/GameZone/tree/main/Games/Dsa_quiz_game) |
| [Gravity_Simulation_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Gravity_Simulation_Game)
| [Anagarm-Word-Game](https://github.com/kunjgit/GameZone/tree/main/Games/Anagarm-Word-Game) |
| [Brick Buster Game](https://github.com/kunjgit/GameZone/tree/main/Games/Brick Buster) |
| [Rapid_click_frenzy](https://github.com/kunjgit/GameZone/tree/main/Games/Rapid_click_frenzy)
=======
| [SnakeBites](https://github.com/kunjgit/GameZone/tree/main/Games/SnakeBites) |
| [Rapid_click_frenzy](https://github.com/kunjgit/GameZone/tree/main/Games/Rapid_click_frenzy)
| [Alphabet-and-Vowels](https://github.com/kunjgit/GameZone/tree/main/Games/Alphabet-and-Vowels) |
| [Brick Buster Game](https://github.com/kunjgit/GameZone/tree/main/Games/Brick%20Buster) |
| [Penguins Can't Fly](https://github.com/Will2Jacks/GameZoneForked/tree/Task/Games/Penguins_Can't_Fly) |
Expand All @@ -811,8 +811,8 @@ This repository also provides one such platforms where contributers come over an
| [Modulo_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Modulo_Game) |
| [Memory_Matching_Game](https://github.com/Saipradyumnagoud/GameZone/tree/main/Games/Memory_Matching_Game) |
|[Penguins Can't Fly](https://github.com/Will2Jacks/GameZoneForked/tree/Task/Games/Penguins_Can't_Fly)|
| [Block_Ninja] (https://github.com/kunjgit/GameZone/tree/main/Games/Block_Ninja) |
| [Shoot_Duck_Game] (https://github.com/kunjgit/GameZone/tree/main/Games/Shoot_Duck_Game) |
| [Block_Ninja] (https://github.com/kunjgit/GameZone/tree/main/Games/Block_Ninja) |
| [Shoot_Duck_Game] (https://github.com/kunjgit/GameZone/tree/main/Games/Shoot_Duck_Game) |
| [Disney_Trivia](https://github.com/manmita/GameZone/tree/Disney_Trivia/Games/Disney_Trivia)|
|[puzzle-game](https://github.com/kunjgit/GameZone/tree/main/Games/puzzle-game)|
| [Helicopter_Game](https://github.com/kinjgit/GameZone/tree/main/Games/Helicopter_Game) |
Expand All @@ -823,7 +823,7 @@ This repository also provides one such platforms where contributers come over an
|[Math_Race_Game](https://github.com/kunjgit/GameZone/tree/main/Games/Math_Race_Game)|
| [Bunny is Lost](https://github.com/kunjgit/GameZone/tree/main/Games/Bunny_is_Lost)|
|[Steam_Punk](https://github.com/kunjgit/GameZone/tree/main/Games/Steam_Punk)|
|[Tower Defence Game](https://github.com/Will2Jacks/GameZoneForked/tree/Task/Games/Tower_Defence_Game)|
|[Tower Defence Game](https://github.com/Will2Jacks/GameZoneForked/tree/Task/Games/Tower_Defence_Game) | | [Ant Smasher Game](https://github.com/kunjgit/GameZone/tree/main/Games/Ant_Smasher)|
|[Mario Matching Game](https://github.com/ananyag309/GameZone_ggsoc/tree/main/Games/MarioMatchingGame)|
|[Dot_Dash](https://github.com/kunjgit/GameZone/tree/main/Games/Dot_Dash)|
|[Ghost Busting Game](https://github.com/kunjgit/GameZone/tree/main/Games/Ghost_busting_game)|
Expand Down
Binary file added assets/images/Ant_Smasher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/Ant_Smasher_Demo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 671a572

Please sign in to comment.