-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #169 from AaadityaG/BubbleGame
Add: Bubble Game
- Loading branch information
Showing
6 changed files
with
229 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Bubble-Game (<a href="https://bubble-game-roan.vercel.app/">Demo</a>) | ||
|
||
Deployed - https://bubble-game-roan.vercel.app/ | ||
|
||
https://github.com/AaadityaG/Bubble-Game/assets/114663382/3e183b5a-269f-4852-8243-cd910ff54e40 | ||
|
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,34 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Bubble Game</title> | ||
<link rel="stylesheet" href="style.css"> | ||
</head> | ||
<body> | ||
<div id="main"> | ||
<div id="panel"> | ||
<div id="ptop"> | ||
<div class="elem"> | ||
<h2>Hit</h2> | ||
<div id="hitVal" class="box"></div> | ||
</div> | ||
<div class="elem"> | ||
<h2>Timer</h2> | ||
<div id="timerVal"class="box"></div> | ||
</div> | ||
<div class="elem"> | ||
<h2>Score</h2> | ||
<div id="scoreVal" class="box"></div> | ||
</div> | ||
</div> | ||
<div id="pbtm"> | ||
</div> | ||
</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,53 @@ | ||
let score = 0; | ||
function increaseScore(){ | ||
score += 10; | ||
document.querySelector('#scoreVal').textContent= score; | ||
} | ||
|
||
|
||
|
||
function makeBubble(){ | ||
let clutter = ""; | ||
|
||
for(let i = 1; i <= 105; i++){ | ||
let rn = Math.floor(Math.random()*10); | ||
clutter += `<div class="bubble">${rn}</div>`; | ||
} | ||
|
||
document.querySelector("#pbtm").innerHTML = clutter; | ||
} | ||
|
||
let timer = 60; | ||
function runTimer(){ | ||
let inter = setInterval(function(){ | ||
if(timer > 0){ | ||
timer--; | ||
document.querySelector('#timerVal').textContent = timer; | ||
} | ||
else{ | ||
clearInterval(inter); | ||
document.querySelector("#pbtm").innerHTML = `<button onclick="window.location.reload();">Start Again</button>` ; | ||
} | ||
}, 1000); | ||
} | ||
|
||
let rdn = 0; | ||
function getNewHit(){ | ||
rdn = Math.floor(Math.random()*10); | ||
document.querySelector("#hitVal").textContent = rdn; | ||
} | ||
|
||
document.querySelector("#pbtm").addEventListener("click", (det)=>{ | ||
// alert("chal raha hai.."); | ||
let clickedNum = Number(det.target.textContent); | ||
if(clickedNum === rdn){ | ||
increaseScore(); | ||
makeBubble(); | ||
getNewHit(); | ||
} | ||
}) | ||
|
||
runTimer(); | ||
makeBubble(); | ||
getNewHit(); | ||
increaseScore(); |
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,127 @@ | ||
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@200;300;400;500&display=swap'); | ||
|
||
*{ | ||
margin: 0; | ||
padding: 0; | ||
box-sizing: border-box; | ||
font-family: 'Poppins', sans-serif; | ||
} | ||
|
||
html, body{ | ||
width: 100%; | ||
height: 100%; | ||
} | ||
|
||
#main{ | ||
width: 100%; | ||
height: 100%; | ||
background-color: #76c8ff; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
|
||
#panel{ | ||
overflow: hidden; | ||
width: 80%; | ||
height: 80%; | ||
background-color: white; | ||
border-radius: 10px; | ||
} | ||
|
||
#ptop{ | ||
display: flex; | ||
color: white; | ||
padding: 0 30%; | ||
align-items: center; | ||
justify-content: space-between; | ||
width: 100%; | ||
height: 100px; | ||
background-color: #0a8ba2; | ||
} | ||
|
||
.elem{ | ||
display: flex; | ||
align-items: center; | ||
gap: 10px; | ||
} | ||
|
||
.elem h3{ | ||
font-weight: 500; | ||
} | ||
|
||
.box{ | ||
color: #064c7a; | ||
font-weight: 500; | ||
padding: 10px 20px; | ||
border-radius: 5px; | ||
background-color: white; | ||
} | ||
|
||
#pbtm{ | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
gap: 10px; | ||
flex-wrap: wrap; | ||
width: 100%; | ||
height: calc(100% - 100px); | ||
background-color: #c5e3ff; | ||
padding: 20px; | ||
} | ||
|
||
#pbtm button{ | ||
display: block; | ||
padding: 10px; | ||
background-color:#0a8ba2; | ||
color: white; | ||
border: none; | ||
border-radius: 5px; | ||
} | ||
|
||
#pbtm button:hover{ | ||
background-color:#08798d; | ||
} | ||
|
||
.bubble{ | ||
width: 60px; | ||
height: 60px; | ||
background-color: #0b6d7a; | ||
color: white; | ||
border-radius: 50%; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
font-weight: 500; | ||
} | ||
|
||
.bubble:hover{ | ||
background-color: #064952; | ||
} | ||
|
||
|
||
/* responsive */ | ||
|
||
@media screen and (width < 480px) { | ||
#ptop{ | ||
padding: 0 3%; | ||
} | ||
#ptop h2{ | ||
font-size: 18px; | ||
} | ||
.box{ | ||
padding: 10px; | ||
} | ||
|
||
#pbtm{ | ||
padding: 10px; | ||
} | ||
} | ||
|
||
@media screen and (width < 912px){ | ||
#ptop{ | ||
align-items: center; | ||
justify-content: center; | ||
gap: 30px; | ||
} | ||
} |
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