index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Click Shape Game</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="game-container">
<p class="score">Score: <span id="score">0</span></p>
<div class="shape" id="shape"></div>
</div>
<script src="script.js"></script>
</body>
</html>
styles.css
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
.game-container {
text-align: center;
}
.shape {
width: 100px;
height: 100px;
background-color: #3498db;
border-radius: 50%;
margin: 20px auto;
cursor: pointer;
}
.score {
font-size: 24px;
}
script.js
let score = 0;
function getRandomPosition() {
const shape = document.getElementById('shape');
const maxWidth = window.innerWidth - shape.clientWidth;
const maxHeight = window.innerHeight - shape.clientHeight;
const randomX = Math.floor(Math.random() * maxWidth);
const randomY = Math.floor(Math.random() * maxHeight);
shape.style.left = `${randomX}px`;
shape.style.top = `${randomY}px`;
}
function increaseScore() {
score++;
document.getElementById('score').innerText = score;
getRandomPosition();
}
document.getElementById('shape').addEventListener('click', increaseScore);
getRandomPosition();
STRUCTURE (Submit after Mid Term , 15 Ashad 2083) A) MCQ 1. What is the…
FUNCTION (Assignment) Submit Before Mid Term MCQ 1. What is the output of this statement…
Evolution History of computer Technology (HISTORY OF COMPUTER) Evolution of computer is a study of…
Unit3_ClassMethodDesign_OOAD DOWNLOAD
Maturity of Enterprise Architecture Practice Maturity of Enterprise Architecture Practice DOWNLOAD
Report-on-final-project_Sample_2