<html>
<head>
  <title>Simple HTML Game - Click Frenzy</title>
</head>
<body>
  <h1>Welcome to the HTML Game!</h1>
  <p>Press the button below to start the game!</p>
<p><button onclick='startGame()'>Start Game</button></p>
  <div id='game'></div>
  <script>
    let score = 0;

    function startGame() {
      score = 0;
      document.getElementById('game').innerHTML = `
        <h2>Let's begin!</h2>
        <p>You will have 5 seconds to click on the button as many times as you can.</p>
        <button onclick='incrementScore()'>Click Here!</button>`;
      setTimeout(endGame, 5000);
    }

    function incrementScore() {
      score++;
    }

    function endGame() {
      document.getElementById('game').innerHTML = `
        <h2>Game Over!</h2>
        <p>Your score is ${score}.</p>
        <button onclick='startGame()'>Play Again</button>`;
    }
  </script>
</body>
</html>
Simple HTML Game - Click Frenzy

原文地址: https://www.cveoy.top/t/topic/lmlH 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录