Game Code
Game Code
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,
initial-scale=1.0">
<title>Click the Circle Game</title>
<style>
body {
text-align: center;
font-family: Arial, sans-serif;
}
#gameArea {
width: 400px;
height: 400px;
border: 2px solid black;
margin: auto;
position: relative;
overflow: hidden;
}
#circle {
width: 50px;
height: 50px;
background-color: red;
border-radius: 50%;
position: absolute;
}
</style>
</head>
<body>
<script>
let score = 0;
const circle = document.getElementById("circle");
const scoreDisplay = document.getElementById("score");
function moveCircle() {
const x = Math.random() * 350;
const y = Math.random() * 350;
circle.style.left = x + "px";
circle.style.top = y + "px";
}
circle.addEventListener("click", () => {
score++;
scoreDisplay.textContent = score;
moveCircle();
});
moveCircle();
</script>
</body>
</html>