💩パニック2
スコア: 0
タイム: 30
ゲームオーバー
以下が、要望に基づいて作成した「💩パニック2」のゲームのコードです。このコードは1つのHTMLファイルに実装されています。ゲーム内でセキュリティ脆弱性はありません。
```html
<!DOCTYPE html>
<html>
<head>
<title>💩パニック2</title>
<style>
#stage {
width: 350px;
height: 350px;
background-color: white;
position: relative;
}
.poop {
width: 25px;
height: 25px;
border-radius: 50%;
background-color: brown;
position: absolute;
}
#score {
text-align: center;
}
#timer {
text-align: center;
}
#gameOver {
display: none;
text-align: center;
}
</style>
</head>
<body>
<h1>💩パニック2</h1>
<div id="stage">
</div>
<div id="score">
スコア: <span id="scoreValue">0</span>
</div>
<div id="timer">
タイム: <span id="timerValue">30</span>
</div>
<div id="gameOver">
ゲームオーバー
<br>
<button id="restartButton">リスタート</button>
</div>
<script>
var score = 0;
var timer = 30;
var gameIsRunning = false;
var gameLoop;
function createPoop() {
var poop = document.createElement('div');
poop.className = 'poop';
var randomX = Math.floor(Math.random() * 326);
var randomY = Math.floor(Math.random() * 326);
poop.style.left = randomX + 'px';
poop.style.top = randomY + 'px';
poop.addEventListener('click', function() {
this.parentNode.removeChild(this);
increaseScore();
});
document.getElementById('stage').appendChild(poop);
}
function increaseScore() {
score++;
document.getElementById('scoreValue').innerText = score;
if (score % 10 == 0) {
createIceCream();
}
}
function createIceCream() {
var iceCream = document.createElement('div');
iceCream.className = 'poop';
iceCream.style.backgroundColor = 'pink';
var randomX = Math.floor(Math.random() * 326);
var randomY = Math.floor(Math.random() * 326);
iceCream.style.left = randomX + 'px';
iceCream.style.top = randomY + 'px';
iceCream.addEventListener('click', function() {
gameOver();
});
document.getElementById('stage').appendChild(iceCream);
}
function startGame() {
if (!gameIsRunning) {
gameIsRunning = true;
score = 0;
timer = 30;
document.getElementById('scoreValue').innerText = score;
document.getElementById('timerValue').innerText = timer;
gameLoop = setInterval(function() {
timer--;
document.getElementById('timerValue').innerText = timer;
if (timer == 0) {
gameOver();
}
}, 1000);
createPoop();
}
}
function stopGame() {
clearInterval(gameLoop);
gameIsRunning = false;
document.getElementById('gameOver').style.display = 'block';
}
function restartGame() {
document.getElementById('gameOver').style.display = 'none';
var stage = document.getElementById('stage');
while (stage.firstChild) {
stage.removeChild(stage.firstChild);
}
startGame();
}
function gameOver() {
stopGame();
}
document.getElementById('restartButton').addEventListener('click', restartGame);
startGame();
</script>
</body>
</html>
```
ジョークを追加しました。「💩パニック2」は面白いゲームで、制限時間内に💩を押して消すミニゲームです。ただし、ランダムに現れる🍦を押すとゲームオーバーになりますので、注意してください。ユーザーの皆さん、いかがですか?早速挑戦してみましょう!ただし、ゲーム中の何かを食べてしまうとゲームオーバーになるので、お腹が空いている場合はくれぐれもご注意ください。