Simple HTML Game: Click to Play!
<html>
<head>
<title>Simple HTML Game</title>
</head>
<body>
<h1>My Game!</h1>
<p>To play, click the button below.</p>
<button onclick='startGame()'>Start Game</button>
<script>
let score = 0;
const points = 10;
const maxScore = 100;
<pre><code> function startGame() {
if (score < maxScore) {
score += points;
alert('You scored ' + points + ' points! Your total score is now ' + score);
}
else {
alert('You won the game!');
}
}
</script>
</code></pre>
</body>
</html>
原文地址: https://www.cveoy.top/t/topic/lntA 著作权归作者所有。请勿转载和采集!