Spaces:
Running
Running
File size: 4,017 Bytes
e20ca6b 2215ceb 35b3151 b3b859c 35b3151 b3b859c 35b3151 b3b859c 35b3151 b3b859c 35b3151 b3b859c 35b3151 b3b859c 35b3151 b3b859c 35b3151 b3b859c 35b3151 b3b859c 35b3151 b3b859c 35b3151 b3b859c 35b3151 b3b859c 35b3151 b3b859c 35b3151 b3b859c 35b3151 b3b859c 35b3151 2215ceb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
<!DOCTYPE html>
<html>
<head>
<title>Click the Box Game</title>
<meta charset="UTF-8" />
<style>
body {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
font-family: sans-serif;
background-color: #f0f0f0;
}
h1 {
margin-bottom: 10px;
}
#gameArea {
width: 300px;
height: 300px;
background-color: #fff;
border: 2px solid #333;
position: relative;
overflow: hidden;
}
#box {
width: 50px;
height: 50px;
background-color: #ff0066;
position: absolute;
cursor: pointer;
}
#score, #timer, #level {
margin: 8px;
font-weight: bold;
}
#level-up-msg {
font-size: 24px;
color: green;
margin-top: 10px;
height: 30px;
}
</style>
</head>
<body>
<h1>π― Click the Box!</h1>
<div id="score">Score: 0</div>
<div id="level">Level: 1</div>
<div id="timer">Time: 30s</div>
<div id="level-up-msg"></div>
<div id="gameArea">
<div id="box"></div>
</div>
<!-- Sound effect -->
<audio id="click-sound" src="https://www.soundjay.com/buttons/sounds/button-16.mp3" preload="auto"></audio>
<script>
let score = 0;
let timeLeft = 30;
let level = 1;
let speed = 1000; // box movement interval in ms
let interval;
const scoreDisplay = document.getElementById("score");
const timerDisplay = document.getElementById("timer");
const levelDisplay = document.getElementById("level");
const box = document.getElementById("box");
const gameArea = document.getElementById("gameArea");
const levelUpMsg = document.getElementById("level-up-msg");
const clickSound = document.getElementById("click-sound");
function moveBox() {
const maxX = gameArea.clientWidth - box.clientWidth;
const maxY = gameArea.clientHeight - box.clientHeight;
const x = Math.floor(Math.random() * maxX);
const y = Math.floor(Math.random() * maxY);
box.style.left = x + "px";
box.style.top = y + "px";
}
function updateLevel() {
if (score === 5 || score === 10 || score === 15) {
level++;
levelDisplay.textContent = "Level: " + level;
levelUpMsg.textContent = `π Level Up! Welcome to Level ${level}!`;
setTimeout(() => (levelUpMsg.textContent = ""), 2000);
clearInterval(interval);
speed -= 200; // make it faster
interval = setInterval(moveBox, speed);
}
}
box.addEventListener("click", () => {
score++;
scoreDisplay.textContent = "Score: " + score;
clickSound.play();
moveBox();
updateLevel();
});
function startGame() {
moveBox();
interval = setInterval(moveBox, speed);
const timer = setInterval(() => {
timeLeft--;
timerDisplay.textContent = "Time: " + timeLeft + "s";
if (timeLeft === 0) {
clearInterval(timer);
clearInterval(interval);
box.style.display = "none";
timerDisplay.textContent = "β° Time's up!";
levelUpMsg.textContent = `π Final Score: ${score} | Level: ${level}`;
}
}, 1000);
}
startGame();
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 𧬠<a href="https://enzostvs-deepsite.hf.space?remix=rukundob451/readyletsgo" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>
|