Skip to content
Open
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
8 changes: 6 additions & 2 deletions Games/Ant_Smasher/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
</head>
<body>

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


<div class="game">
<div class="hole hole1">
Expand Down
16 changes: 14 additions & 2 deletions Games/Ant_Smasher/script.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
const holes = document.querySelectorAll(".hole");
const scoreBoard = document.querySelector(".score");
const scoreBoard = document.querySelectorAll(".score")[0];
const finalScore = document.querySelectorAll(".score")[1];
const moles = document.querySelectorAll(".mole");
let lastHole;
let timeUp = false;
let score = 0;
let totalScore = 0;

function randomTime(min, max) {
return Math.round(Math.random() * (max - min) + min);
Expand All @@ -22,6 +24,7 @@ function randomHole(holes) {
function peep() {
const time = randomTime(500, 2000);
const hole = randomHole(holes);
totalScore++;
hole.classList.add("up");
setTimeout(() => {
hole.classList.remove("up");
Expand All @@ -31,17 +34,26 @@ function peep() {

function startGame() {
scoreBoard.textContent = 0;
finalScore.textContent = 0;
timeUp = false;
score = 0;
totalScore = 0;

peep();
setTimeout(() => (timeUp = true), 10000);
setTimeout(() => {
timeUp = true;
finalScore.textContent = score+ '/' + totalScore;
}, 10000);
}

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

moles.forEach((mole) => mole.addEventListener("click", bonk));
46 changes: 40 additions & 6 deletions Games/Ant_Smasher/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,39 @@ body {
padding: 0;
margin: 0;
font-family: "Amatic SC", cursive;
position: relative;
}

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

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

.game {
width: 600px;
height: 400px;
width: 80vw;
max-width: 1000px;
height: 60vh;
min-height: 400px;
display: flex;
flex-wrap: wrap;
margin: 0 auto;
padding: 20px;
}

.hole {
flex: 1 0 33.33%;
overflow: hidden;
position: relative;
min-height: 300px;
}

.hole:after {
Expand All @@ -51,10 +56,10 @@ h1 {
background-size: contain;
content: "";
width: 100%;
height: 70px;
height: 120px;
position: absolute;
z-index: 2;
bottom: -30px;
bottom: -50px;
}

.mole {
Expand All @@ -70,3 +75,32 @@ h1 {
.hole.up .mole {
top: 0;
}

button {
background-color: #ff6b6b;
color: white;
font-size: 20px;
font-weight: bold;
padding: 15px 30px;
border: 3px solid #333;
border-radius: 10px;
cursor: pointer;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
transition: all 0.3s ease;
position: absolute;
left: 50%;
transform: translateX(-50%);
top: 40px;
z-index: 10;
}

button:hover {
background-color: #ff5252;
transform: translateX(-50%) scale(1.05);
box-shadow: 0 6px 8px rgba(0, 0, 0, 0.4);
}

button:active {
transform: translateX(-50%) scale(0.95);
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
Binary file modified 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.
Binary file added assets/images/Ant_Smasher_Demo_Final.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.