File: /home/internet/public_html/advik.xyz/ball.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Balloon Pop Game</title>
<style>
body {
margin: 0;
overflow: hidden;
background: linear-gradient(to bottom, #87CEEB, #ffffff);
text-align: center;
font-family: Arial, sans-serif;
}
#score {
position: absolute;
top: 10px;
left: 50%;
transform: translateX(-50%);
font-size: 24px;
background: rgba(0, 0, 0, 0.5);
color: white;
padding: 10px 20px;
border-radius: 10px;
}
.balloon {
position: absolute;
width: 60px;
height: 80px;
background: red;
border-radius: 50%;
cursor: pointer;
box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.2);
}
</style>
</head>
<body>
<div id="score">Score: 0</div>
<script>
let score = 0;
function createBalloon() {
const balloon = document.createElement("div");
balloon.classList.add("balloon");
balloon.style.background = getRandomColor();
balloon.style.left = Math.random() * window.innerWidth + "px";
document.body.appendChild(balloon);
let moveUp = setInterval(() => {
let topPos = parseInt(balloon.style.top || window.innerHeight) - 3;
if (topPos < -100) {
clearInterval(moveUp);
balloon.remove();
} else {
balloon.style.top = topPos + "px";
}
}, 20);
balloon.addEventListener("click", () => {
clearInterval(moveUp);
balloon.remove();
score++;
document.getElementById("score").innerText = "Score: " + score;
});
}
function getRandomColor() {
const colors = ["red", "blue", "green", "yellow", "purple", "orange"];
return colors[Math.floor(Math.random() * colors.length)];
}
setInterval(createBalloon, 1000);
</script>
</body>
</html>