素数カウントゲーム
履歴:
カブト虫
イチジクのタルト
ジョット
ドロローサへの道
カブト虫
秘密の皇帝
カブト虫
らせん階段
廃墟の街
特異点
特異点
紫陽花
天使(エンジェル)
カブト虫
<!DOCTYPE html>
<html>
<head>
<title>素数カウントゲーム</title>
<style>
body {
background-color: #fefefe;
text-align: center;
margin: 0;
padding: 0;
font-size: 24px;
font-family: 'Helvetica Neue', san-serif;
}
h1 {
font-size: 48px;
margin-top: 50px;
}
button {
background-color: #008CBA;
color: #fff;
padding: 20px;
border: none;
border-radius: 5px;
font-size: 24px;
cursor: pointer;
margin-top: 50px;
}
.text {
margin-top: 50px;
}
.completed {
color: green;
}
.history {
margin-top: 50px;
font-size: 18px;
text-align: left;
max-height: 200px;
overflow: auto;
}
.background {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
background-color: #fefefe;
z-index: -1;
}
.scroll {
height: 100%;
width: 100%;
position: absolute;
top: 0;
left: 0;
background-color: transparent;
color: #FFFFFF;
font-size: 36px;
text-align: center;
overflow: hidden;
animation: scroll 10s linear;
animation-timing-function: ease-out;
}
@keyframes scroll {
0% {
transform: translateY(0);
}
100% {
transform: translateY(-100vh);
}
}
</style>
</head>
<body>
<h1>素数カウントゲーム</h1>
<button id="countButton">素数カウント</button>
<div class="text">
<p id="count"></p>
<p id="message"></p>
</div>
<p class="history">履歴:</p>
<ul id="historyList"></ul>
<div class="background"></div>
<div class="scroll">
<p>カブト虫</p>
<p>イチジクのタルト</p>
<p>ジョット</p>
<p>ドロローサへの道</p>
<p>カブト虫</p>
<p>秘密の皇帝</p>
<p>カブト虫</p>
<p>らせん階段</p>
<p>廃墟の街</p>
<p>特異点</p>
<p>特異点</p>
<p>紫陽花</p>
<p>天使(エンジェル)</p>
<p>カブト虫</p>
</div>
<script>
// 初期化
let count = 0;
let isPrime = true;
let history = [];
let completed = false;
// ボタンクリック時の処理
document.getElementById('countButton').addEventListener('click', function() {
if (completed) {
return;
}
count++;
isPrime = true;
for (let i = 2; i < count; i++) {
if (count % i === 0) {
isPrime = false;
break;
}
}
if (isPrime) {
document.getElementById('message').innerHTML = getRandomMessage();
history.push(count);
addToHistoryList(count);
checkCompleted();
}
document.getElementById('count').innerHTML = count;
});
// ランダムなメッセージを取得
function getRandomMessage() {
const messages = [
'カブト虫',
'イチジクのタルト',
'ジョット',
'ドロローサへの道',
'カブト虫',
'秘密の皇帝',
'カブト虫',
'らせん階段',
'廃墟の街',
'特異点',
'特異点',
'紫陽花',
'天使(エンジェル)',
'カブト虫'
];
return messages[Math.floor(Math.random() * messages.length)];
}
// 履歴に要素を追加
function addToHistoryList(number) {
const li = document.createElement('li');
li.innerHTML = number;
document.getElementById('historyList').appendChild(li);
}
// 完成判定
function checkCompleted() {
if (history.length === 14) {
const message = document.getElementById('message');
message.innerHTML = "『天にまします主よ。わたしを導いてください…わたしが間違った道を歩まぬよう見守っていてください…あなたの御心に我が身を捧げます』";
message.classList.add('completed');
setTimeout(function() {
document.querySelector('.scroll').style.display = 'block';
document.querySelector('.background').style.backgroundColor = '#800080';
setTimeout(function() {
document.getElementById('countButton').style.display = 'none';
message.innerHTML = '感じたぞッ!『位置』が来るッ!';
setTimeout(function() {
message.innerHTML = 'メイド・イン・ヘヴン!!!';
document.querySelector('.scroll').style.display = 'none';
document.querySelector('.background').style.backgroundColor = '#fefefe';
document.getElementById('countButton').style.display = 'inline-block';
history = [];
completed = false;
}, 1000);
}, 5000);
}, 1000);
completed = true;
}
}
</script>
</body>
</html>