タイマーアプリ
00:00
賞金: 0 円
<!DOCTYPE html>
<html>
<head>
<title>タイマーアプリ</title>
<script>
let time = 0;
let interval;
const moneyPerSecond = 200;
const totalTime = 100 * 60; // 100分
let money = 0;
function startTimer() {
interval = setInterval(function() {
time++;
money = time * moneyPerSecond; // 賞金計算
document.getElementById('timer').innerText = formatTime(totalTime - time);
document.getElementById('money').innerText = `賞金: ${money} 円`;
if (time === totalTime) {
clearInterval(interval);
document.getElementById('timer').innerText = "時間終了!";
document.getElementById('money').innerText = `最終賞金: ${money} 円`;
}
}, 1000);
}
function formatTime(seconds) {
const minutes = Math.floor(seconds / 60);
const secs = seconds % 60;
return `${minutes.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`;
}
</script>
</head>
<body>
<h1>タイマーアプリ</h1>
<div>
<p id="timer">00:00</p>
<p id="money">賞金: 0 円</p>
</div>
<button onclick="startTimer()">Start</button>
</body>
</html>