Spaces:
Running
Running
Upload 12 files
Browse files- index.html +1 -1
- prologue.js +6 -3
- spring.css +218 -0
- spring.html +67 -0
- spring.js +177 -0
- style.css +210 -4
index.html
CHANGED
|
@@ -6,7 +6,7 @@
|
|
| 6 |
<title>數學魔法王國:平方之旅</title>
|
| 7 |
<link rel="stylesheet" href="style.css">
|
| 8 |
</head>
|
| 9 |
-
<body>
|
| 10 |
<div class="game-container">
|
| 11 |
<h1 class="game-title">《數學魔法王國:平方之旅》</h1>
|
| 12 |
|
|
|
|
| 6 |
<title>數學魔法王國:平方之旅</title>
|
| 7 |
<link rel="stylesheet" href="style.css">
|
| 8 |
</head>
|
| 9 |
+
<body class="home-page">
|
| 10 |
<div class="game-container">
|
| 11 |
<h1 class="game-title">《數學魔法王國:平方之旅》</h1>
|
| 12 |
|
prologue.js
CHANGED
|
@@ -22,11 +22,14 @@ document.addEventListener('DOMContentLoaded', function() {
|
|
| 22 |
|
| 23 |
// 繼續旅程按鈕點擊事件
|
| 24 |
continueJourneyBtn.addEventListener('click', function() {
|
| 25 |
-
//
|
| 26 |
-
|
| 27 |
|
| 28 |
// 更新遊戲進度
|
| 29 |
-
const gameProgress = JSON.parse(localStorage.getItem(`gameProgress_${currentPlayerId}`));
|
|
|
|
|
|
|
|
|
|
| 30 |
gameProgress.currentLocation = "平方之泉";
|
| 31 |
gameProgress.lastSaved = new Date().toISOString();
|
| 32 |
localStorage.setItem(`gameProgress_${currentPlayerId}`, JSON.stringify(gameProgress));
|
|
|
|
| 22 |
|
| 23 |
// 繼續旅程按鈕點擊事件
|
| 24 |
continueJourneyBtn.addEventListener('click', function() {
|
| 25 |
+
// 導向第一個試煉「平方之泉」
|
| 26 |
+
window.location.href = 'spring.html';
|
| 27 |
|
| 28 |
// 更新遊戲進度
|
| 29 |
+
const gameProgress = JSON.parse(localStorage.getItem(`gameProgress_${currentPlayerId}`)) || {};
|
| 30 |
+
if (!gameProgress.completedTrials) {
|
| 31 |
+
gameProgress.completedTrials = {};
|
| 32 |
+
}
|
| 33 |
gameProgress.currentLocation = "平方之泉";
|
| 34 |
gameProgress.lastSaved = new Date().toISOString();
|
| 35 |
localStorage.setItem(`gameProgress_${currentPlayerId}`, JSON.stringify(gameProgress));
|
spring.css
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* 平方之泉頁面樣式 */
|
| 2 |
+
body.spring-page {
|
| 3 |
+
background-image: url('guardian.jpg');
|
| 4 |
+
}
|
| 5 |
+
|
| 6 |
+
.spring-container {
|
| 7 |
+
background-color: rgba(0, 0, 0, 0.7);
|
| 8 |
+
border: 3px solid rgba(255, 140, 0, 0.7);
|
| 9 |
+
border-radius: 10px;
|
| 10 |
+
padding: 30px;
|
| 11 |
+
width: 90%;
|
| 12 |
+
max-width: 800px;
|
| 13 |
+
margin: 0 auto;
|
| 14 |
+
color: white;
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
.spring-title {
|
| 18 |
+
color: rgba(255, 165, 0, 0.9);
|
| 19 |
+
font-size: 2rem;
|
| 20 |
+
margin-bottom: 30px;
|
| 21 |
+
text-align: center;
|
| 22 |
+
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
.spring-content {
|
| 26 |
+
line-height: 1.8;
|
| 27 |
+
font-size: 1.1rem;
|
| 28 |
+
margin-bottom: 30px;
|
| 29 |
+
text-align: justify;
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
.spring-content p {
|
| 33 |
+
margin-bottom: 15px;
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
.start-challenge-container {
|
| 37 |
+
text-align: center;
|
| 38 |
+
margin-top: 30px;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
/* 問答區域樣式 */
|
| 42 |
+
.quiz-container {
|
| 43 |
+
padding: 20px;
|
| 44 |
+
margin-bottom: 30px;
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
#question-container {
|
| 48 |
+
margin-bottom: 30px;
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
#question-text {
|
| 52 |
+
font-size: 1.5rem;
|
| 53 |
+
margin-bottom: 20px;
|
| 54 |
+
color: rgba(255, 165, 0, 0.9);
|
| 55 |
+
text-align: center;
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
#options-container {
|
| 59 |
+
display: grid;
|
| 60 |
+
grid-template-columns: repeat(2, 1fr);
|
| 61 |
+
gap: 15px;
|
| 62 |
+
margin-bottom: 20px;
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
.option-btn {
|
| 66 |
+
padding: 15px;
|
| 67 |
+
background-color: rgba(255, 140, 0, 0.6);
|
| 68 |
+
color: white;
|
| 69 |
+
border: 2px solid rgba(255, 165, 0, 0.8);
|
| 70 |
+
border-radius: 8px;
|
| 71 |
+
font-size: 1.1rem;
|
| 72 |
+
cursor: pointer;
|
| 73 |
+
transition: all 0.3s;
|
| 74 |
+
text-align: center;
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
.option-btn:hover {
|
| 78 |
+
background-color: rgba(255, 165, 0, 0.8);
|
| 79 |
+
transform: translateY(-3px);
|
| 80 |
+
box-shadow: 0 5px 15px rgba(255, 140, 0, 0.4);
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
.option-btn.correct {
|
| 84 |
+
background-color: rgba(0, 200, 0, 0.8);
|
| 85 |
+
border-color: rgba(0, 255, 0, 0.8);
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
.option-btn.incorrect {
|
| 89 |
+
background-color: rgba(200, 0, 0, 0.8);
|
| 90 |
+
border-color: rgba(255, 0, 0, 0.8);
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
.option-btn.disabled {
|
| 94 |
+
cursor: not-allowed;
|
| 95 |
+
opacity: 0.7;
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
/* 泉水動畫區域 */
|
| 99 |
+
.spring-animation {
|
| 100 |
+
height: 150px;
|
| 101 |
+
margin: 30px 0;
|
| 102 |
+
position: relative;
|
| 103 |
+
overflow: hidden;
|
| 104 |
+
border-radius: 10px;
|
| 105 |
+
background-color: rgba(0, 100, 255, 0.3);
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
.water-ripple {
|
| 109 |
+
position: absolute;
|
| 110 |
+
top: 50%;
|
| 111 |
+
left: 50%;
|
| 112 |
+
transform: translate(-50%, -50%);
|
| 113 |
+
width: 0;
|
| 114 |
+
height: 0;
|
| 115 |
+
border-radius: 50%;
|
| 116 |
+
background-color: rgba(0, 200, 255, 0.6);
|
| 117 |
+
opacity: 0;
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
.water-ripple.animate {
|
| 121 |
+
animation: ripple 2s ease-out;
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
@keyframes ripple {
|
| 125 |
+
0% {
|
| 126 |
+
width: 0;
|
| 127 |
+
height: 0;
|
| 128 |
+
opacity: 0.8;
|
| 129 |
+
}
|
| 130 |
+
100% {
|
| 131 |
+
width: 300px;
|
| 132 |
+
height: 300px;
|
| 133 |
+
opacity: 0;
|
| 134 |
+
}
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
/* 進度條樣式 */
|
| 138 |
+
.progress-container {
|
| 139 |
+
margin-top: 20px;
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
.progress-text {
|
| 143 |
+
text-align: center;
|
| 144 |
+
margin-bottom: 10px;
|
| 145 |
+
font-size: 1.1rem;
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
.progress-bar {
|
| 149 |
+
height: 15px;
|
| 150 |
+
background-color: rgba(255, 255, 255, 0.2);
|
| 151 |
+
border-radius: 10px;
|
| 152 |
+
overflow: hidden;
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
#progress-fill {
|
| 156 |
+
height: 100%;
|
| 157 |
+
background-color: rgba(255, 165, 0, 0.8);
|
| 158 |
+
width: 0%;
|
| 159 |
+
transition: width 0.5s ease;
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
/* 完成訊息樣式 */
|
| 163 |
+
.completion-message {
|
| 164 |
+
text-align: center;
|
| 165 |
+
padding: 20px;
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
.completion-message h2 {
|
| 169 |
+
color: rgba(255, 215, 0, 0.9);
|
| 170 |
+
font-size: 1.8rem;
|
| 171 |
+
margin-bottom: 20px;
|
| 172 |
+
text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
.completion-message p {
|
| 176 |
+
margin-bottom: 15px;
|
| 177 |
+
font-size: 1.1rem;
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
.feedback-container {
|
| 181 |
+
text-align: center;
|
| 182 |
+
margin: 20px 0;
|
| 183 |
+
font-size: 1.2rem;
|
| 184 |
+
min-height: 30px;
|
| 185 |
+
}
|
| 186 |
+
|
| 187 |
+
/* 響應式設計 */
|
| 188 |
+
@media (max-width: 768px) {
|
| 189 |
+
.spring-title {
|
| 190 |
+
font-size: 1.8rem;
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
#options-container {
|
| 194 |
+
grid-template-columns: 1fr;
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
.option-btn {
|
| 198 |
+
padding: 12px;
|
| 199 |
+
}
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
@media (max-width: 480px) {
|
| 203 |
+
.spring-container {
|
| 204 |
+
padding: 15px;
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
.spring-title {
|
| 208 |
+
font-size: 1.5rem;
|
| 209 |
+
}
|
| 210 |
+
|
| 211 |
+
.spring-content {
|
| 212 |
+
font-size: 1rem;
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
#question-text {
|
| 216 |
+
font-size: 1.3rem;
|
| 217 |
+
}
|
| 218 |
+
}
|
spring.html
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="zh-TW">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>平方之泉 - 數學魔法王國:平方之旅</title>
|
| 7 |
+
<link rel="stylesheet" href="style.css">
|
| 8 |
+
</head>
|
| 9 |
+
<body class="spring-page">
|
| 10 |
+
<div class="game-container">
|
| 11 |
+
<div class="spring-container">
|
| 12 |
+
<h1 class="spring-title">第一試煉:平方之泉</h1>
|
| 13 |
+
|
| 14 |
+
<div class="spring-content" id="story-section">
|
| 15 |
+
<p>這裡是充滿魔法能量的「平方之泉」,但只有熟悉平方力量的人才能吸收泉水力量。</p>
|
| 16 |
+
|
| 17 |
+
<p>守泉獸說道:「1 的平方是 1、2 的平方是 4……你真的記得它們嗎?若你能感受到數字膨脹的力量,你將能邁出第一步。」</p>
|
| 18 |
+
|
| 19 |
+
<p>守泉獸設下了六道考驗,測試你對平方數的直覺感知能力。每答對一題,泉水就會閃爍一次;全部答對,泉水將賦予你「直覺感知」的力量。</p>
|
| 20 |
+
|
| 21 |
+
<div class="start-challenge-container">
|
| 22 |
+
<button id="start-challenge" class="action-btn">開始考驗</button>
|
| 23 |
+
</div>
|
| 24 |
+
</div>
|
| 25 |
+
|
| 26 |
+
<div class="quiz-container" id="quiz-section" style="display: none;">
|
| 27 |
+
<div id="question-container">
|
| 28 |
+
<h2 id="question-text">問題載入中...</h2>
|
| 29 |
+
<div id="options-container">
|
| 30 |
+
<!-- 選項將由JavaScript動態生成 -->
|
| 31 |
+
</div>
|
| 32 |
+
</div>
|
| 33 |
+
|
| 34 |
+
<div id="result-feedback" class="feedback-container">
|
| 35 |
+
<!-- 答題結果反饋將在這裡顯示 -->
|
| 36 |
+
</div>
|
| 37 |
+
|
| 38 |
+
<div class="spring-animation" id="spring-animation">
|
| 39 |
+
<!-- 泉水閃爍動畫區域 -->
|
| 40 |
+
<div class="water-ripple"></div>
|
| 41 |
+
</div>
|
| 42 |
+
|
| 43 |
+
<div class="progress-container">
|
| 44 |
+
<div class="progress-text">進度:<span id="progress-count">0</span>/6</div>
|
| 45 |
+
<div class="progress-bar">
|
| 46 |
+
<div id="progress-fill"></div>
|
| 47 |
+
</div>
|
| 48 |
+
</div>
|
| 49 |
+
</div>
|
| 50 |
+
|
| 51 |
+
<div class="completion-message" id="completion-section" style="display: none;">
|
| 52 |
+
<h2>恭喜你完成第一試煉!</h2>
|
| 53 |
+
<p>泉水閃爍著明亮的光芒,你感受到一股力量流入體內...</p>
|
| 54 |
+
<p>你已獲得「直覺感知」的能力!</p>
|
| 55 |
+
<p>守泉獸欣慰地說:「你已經掌握了平方的基本感知,但這只是開始。真正的勇者需要學會轉換的藝術。前往變換山谷吧,那裡的山谷之靈會教導你下一階段的力量。」</p>
|
| 56 |
+
|
| 57 |
+
<div class="navigation-buttons">
|
| 58 |
+
<button id="back-to-prologue" class="nav-btn">返回序章</button>
|
| 59 |
+
<button id="next-trial" class="nav-btn">前往下一試煉</button>
|
| 60 |
+
</div>
|
| 61 |
+
</div>
|
| 62 |
+
</div>
|
| 63 |
+
</div>
|
| 64 |
+
|
| 65 |
+
<script src="spring.js"></script>
|
| 66 |
+
</body>
|
| 67 |
+
</html>
|
spring.js
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 2 |
+
// 檢查是否有玩家資料
|
| 3 |
+
const currentPlayerId = localStorage.getItem('currentPlayerId');
|
| 4 |
+
const playerName = localStorage.getItem('playerName');
|
| 5 |
+
const playerProfession = localStorage.getItem('playerProfession');
|
| 6 |
+
|
| 7 |
+
// 如果沒有玩家資料,重定向到首頁
|
| 8 |
+
if (!currentPlayerId || !playerName || !playerProfession) {
|
| 9 |
+
alert('請先登入遊戲!');
|
| 10 |
+
window.location.href = 'index.html';
|
| 11 |
+
return;
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
// 獲取DOM元素
|
| 15 |
+
const storySection = document.getElementById('story-section');
|
| 16 |
+
const quizSection = document.getElementById('quiz-section');
|
| 17 |
+
const completionSection = document.getElementById('completion-section');
|
| 18 |
+
const startChallengeBtn = document.getElementById('start-challenge');
|
| 19 |
+
const questionText = document.getElementById('question-text');
|
| 20 |
+
const optionsContainer = document.getElementById('options-container');
|
| 21 |
+
const resultFeedback = document.getElementById('result-feedback');
|
| 22 |
+
const springAnimation = document.getElementById('spring-animation');
|
| 23 |
+
const waterRipple = document.querySelector('.water-ripple');
|
| 24 |
+
const progressCount = document.getElementById('progress-count');
|
| 25 |
+
const progressFill = document.getElementById('progress-fill');
|
| 26 |
+
const backToPrologueBtn = document.getElementById('back-to-prologue');
|
| 27 |
+
const nextTrialBtn = document.getElementById('next-trial');
|
| 28 |
+
|
| 29 |
+
// 問題集
|
| 30 |
+
const questions = [
|
| 31 |
+
{
|
| 32 |
+
question: "Q1. 8 的平方是多少?",
|
| 33 |
+
options: ["(A) 56", "(B) 64", "(C) 72", "(D) 81"],
|
| 34 |
+
correctIndex: 1
|
| 35 |
+
},
|
| 36 |
+
{
|
| 37 |
+
question: "Q2. 哪個數的平方是 121?",
|
| 38 |
+
options: ["(A) 10", "(B) 11", "(C) 12", "(D) 13"],
|
| 39 |
+
correctIndex: 1
|
| 40 |
+
},
|
| 41 |
+
{
|
| 42 |
+
question: "Q3. 5 的平方是多少?",
|
| 43 |
+
options: ["(A) 20", "(B) 30", "(C) 25", "(D) 35"],
|
| 44 |
+
correctIndex: 2
|
| 45 |
+
},
|
| 46 |
+
{
|
| 47 |
+
question: "Q4. 哪個數的平方是 36?",
|
| 48 |
+
options: ["(A) 6", "(B) 7", "(C) 5", "(D) 8"],
|
| 49 |
+
correctIndex: 0
|
| 50 |
+
},
|
| 51 |
+
{
|
| 52 |
+
question: "Q5. 12 的平方是多少?",
|
| 53 |
+
options: ["(A) 124", "(B) 132", "(C) 144", "(D) 154"],
|
| 54 |
+
correctIndex: 2
|
| 55 |
+
},
|
| 56 |
+
{
|
| 57 |
+
question: "Q6. 哪個數的平方是 49?",
|
| 58 |
+
options: ["(A) 6", "(B) 8", "(C) 7", "(D) 9"],
|
| 59 |
+
correctIndex: 2
|
| 60 |
+
}
|
| 61 |
+
];
|
| 62 |
+
|
| 63 |
+
let currentQuestionIndex = 0;
|
| 64 |
+
let correctAnswers = 0;
|
| 65 |
+
|
| 66 |
+
// 開始考驗按鈕點擊事件
|
| 67 |
+
startChallengeBtn.addEventListener('click', function() {
|
| 68 |
+
storySection.style.display = 'none';
|
| 69 |
+
quizSection.style.display = 'block';
|
| 70 |
+
showQuestion(currentQuestionIndex);
|
| 71 |
+
});
|
| 72 |
+
|
| 73 |
+
// 顯示問題
|
| 74 |
+
function showQuestion(index) {
|
| 75 |
+
const question = questions[index];
|
| 76 |
+
questionText.textContent = question.question;
|
| 77 |
+
|
| 78 |
+
// 清空選項容器
|
| 79 |
+
optionsContainer.innerHTML = '';
|
| 80 |
+
|
| 81 |
+
// 添加選項
|
| 82 |
+
question.options.forEach((option, i) => {
|
| 83 |
+
const button = document.createElement('button');
|
| 84 |
+
button.className = 'option-btn';
|
| 85 |
+
button.textContent = option;
|
| 86 |
+
button.dataset.index = i;
|
| 87 |
+
|
| 88 |
+
button.addEventListener('click', function() {
|
| 89 |
+
checkAnswer(i);
|
| 90 |
+
});
|
| 91 |
+
|
| 92 |
+
optionsContainer.appendChild(button);
|
| 93 |
+
});
|
| 94 |
+
|
| 95 |
+
// 清空結果反饋
|
| 96 |
+
resultFeedback.textContent = '';
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
// 檢查答案
|
| 100 |
+
function checkAnswer(selectedIndex) {
|
| 101 |
+
const correctIndex = questions[currentQuestionIndex].correctIndex;
|
| 102 |
+
const optionButtons = document.querySelectorAll('.option-btn');
|
| 103 |
+
|
| 104 |
+
// 禁用所有選項按鈕
|
| 105 |
+
optionButtons.forEach(button => {
|
| 106 |
+
button.classList.add('disabled');
|
| 107 |
+
button.disabled = true;
|
| 108 |
+
});
|
| 109 |
+
|
| 110 |
+
// 標記正確和錯誤的選項
|
| 111 |
+
optionButtons[correctIndex].classList.add('correct');
|
| 112 |
+
|
| 113 |
+
if (selectedIndex !== correctIndex) {
|
| 114 |
+
optionButtons[selectedIndex].classList.add('incorrect');
|
| 115 |
+
resultFeedback.textContent = '答錯了,再接再厲!';
|
| 116 |
+
} else {
|
| 117 |
+
correctAnswers++;
|
| 118 |
+
resultFeedback.textContent = '答對了,太棒了!';
|
| 119 |
+
|
| 120 |
+
// 播放泉水閃爍動畫
|
| 121 |
+
waterRipple.classList.remove('animate');
|
| 122 |
+
setTimeout(() => {
|
| 123 |
+
waterRipple.classList.add('animate');
|
| 124 |
+
}, 10);
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
// 更新進度
|
| 128 |
+
progressCount.textContent = correctAnswers;
|
| 129 |
+
progressFill.style.width = (correctAnswers / questions.length * 100) + '%';
|
| 130 |
+
|
| 131 |
+
// 延遲後進入下一題或完成
|
| 132 |
+
setTimeout(() => {
|
| 133 |
+
currentQuestionIndex++;
|
| 134 |
+
|
| 135 |
+
if (currentQuestionIndex < questions.length) {
|
| 136 |
+
showQuestion(currentQuestionIndex);
|
| 137 |
+
} else {
|
| 138 |
+
// 完成所有問題
|
| 139 |
+
quizSection.style.display = 'none';
|
| 140 |
+
completionSection.style.display = 'block';
|
| 141 |
+
|
| 142 |
+
// 更新遊戲進度
|
| 143 |
+
updateGameProgress();
|
| 144 |
+
}
|
| 145 |
+
}, 2000);
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
// 更新遊戲進度
|
| 149 |
+
function updateGameProgress() {
|
| 150 |
+
const gameProgress = JSON.parse(localStorage.getItem(`gameProgress_${currentPlayerId}`)) || {};
|
| 151 |
+
|
| 152 |
+
if (!gameProgress.completedTrials) {
|
| 153 |
+
gameProgress.completedTrials = {};
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
gameProgress.completedTrials["平方之泉"] = {
|
| 157 |
+
completed: true,
|
| 158 |
+
score: (correctAnswers / questions.length) * 100,
|
| 159 |
+
challengesCompleted: Array(questions.length).fill(false).map((_, i) => i < correctAnswers)
|
| 160 |
+
};
|
| 161 |
+
|
| 162 |
+
gameProgress.currentLocation = "平方之泉";
|
| 163 |
+
gameProgress.lastSaved = new Date().toISOString();
|
| 164 |
+
|
| 165 |
+
localStorage.setItem(`gameProgress_${currentPlayerId}`, JSON.stringify(gameProgress));
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
// 返回序章按鈕點擊事件
|
| 169 |
+
backToPrologueBtn.addEventListener('click', function() {
|
| 170 |
+
window.location.href = 'prologue.html';
|
| 171 |
+
});
|
| 172 |
+
|
| 173 |
+
// 前往下一試煉按鈕點擊事件
|
| 174 |
+
nextTrialBtn.addEventListener('click', function() {
|
| 175 |
+
alert('下一試煉「變換山谷」尚未開放,敬請期待!');
|
| 176 |
+
});
|
| 177 |
+
});
|
style.css
CHANGED
|
@@ -25,6 +25,10 @@ body.prologue-page {
|
|
| 25 |
background-image: url('palace.jpg');
|
| 26 |
}
|
| 27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
.game-container {
|
| 29 |
text-align: center;
|
| 30 |
width: 100%;
|
|
@@ -243,6 +247,188 @@ body.prologue-page {
|
|
| 243 |
box-shadow: 0 0 15px rgba(255, 165, 0, 0.5); /* 橘色光暈 */
|
| 244 |
}
|
| 245 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 246 |
/* 響應式設計 */
|
| 247 |
@media (max-width: 768px) {
|
| 248 |
.game-title {
|
|
@@ -256,17 +442,29 @@ body.prologue-page {
|
|
| 256 |
padding: 15px;
|
| 257 |
}
|
| 258 |
|
| 259 |
-
.prologue-container {
|
| 260 |
padding: 20px;
|
| 261 |
}
|
| 262 |
|
| 263 |
-
.prologue-title {
|
| 264 |
font-size: 1.8rem;
|
| 265 |
}
|
| 266 |
|
| 267 |
-
.prologue-content {
|
| 268 |
font-size: 1rem;
|
| 269 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 270 |
}
|
| 271 |
|
| 272 |
@media (max-width: 480px) {
|
|
@@ -289,7 +487,7 @@ body.prologue-page {
|
|
| 289 |
padding: 15px;
|
| 290 |
}
|
| 291 |
|
| 292 |
-
.prologue-title {
|
| 293 |
font-size: 1.5rem;
|
| 294 |
}
|
| 295 |
|
|
@@ -301,4 +499,12 @@ body.prologue-page {
|
|
| 301 |
.nav-btn {
|
| 302 |
width: 100%;
|
| 303 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 304 |
}
|
|
|
|
| 25 |
background-image: url('palace.jpg');
|
| 26 |
}
|
| 27 |
|
| 28 |
+
body.spring-page {
|
| 29 |
+
background-image: url('guardian.jpg');
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
.game-container {
|
| 33 |
text-align: center;
|
| 34 |
width: 100%;
|
|
|
|
| 247 |
box-shadow: 0 0 15px rgba(255, 165, 0, 0.5); /* 橘色光暈 */
|
| 248 |
}
|
| 249 |
|
| 250 |
+
/* 平方之泉頁面樣式 */
|
| 251 |
+
.spring-container {
|
| 252 |
+
background-color: rgba(0, 0, 0, 0.7);
|
| 253 |
+
border: 3px solid rgba(255, 140, 0, 0.7);
|
| 254 |
+
border-radius: 10px;
|
| 255 |
+
padding: 30px;
|
| 256 |
+
width: 90%;
|
| 257 |
+
max-width: 800px;
|
| 258 |
+
margin: 0 auto;
|
| 259 |
+
color: white;
|
| 260 |
+
}
|
| 261 |
+
|
| 262 |
+
.spring-title {
|
| 263 |
+
color: rgba(255, 165, 0, 0.9);
|
| 264 |
+
font-size: 2rem;
|
| 265 |
+
margin-bottom: 30px;
|
| 266 |
+
text-align: center;
|
| 267 |
+
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
|
| 268 |
+
}
|
| 269 |
+
|
| 270 |
+
.spring-content {
|
| 271 |
+
line-height: 1.8;
|
| 272 |
+
font-size: 1.1rem;
|
| 273 |
+
margin-bottom: 30px;
|
| 274 |
+
text-align: justify;
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
.spring-content p {
|
| 278 |
+
margin-bottom: 15px;
|
| 279 |
+
}
|
| 280 |
+
|
| 281 |
+
.start-challenge-container {
|
| 282 |
+
text-align: center;
|
| 283 |
+
margin-top: 30px;
|
| 284 |
+
}
|
| 285 |
+
|
| 286 |
+
/* 問答區域樣式 */
|
| 287 |
+
.quiz-container {
|
| 288 |
+
padding: 20px;
|
| 289 |
+
margin-bottom: 30px;
|
| 290 |
+
}
|
| 291 |
+
|
| 292 |
+
#question-container {
|
| 293 |
+
margin-bottom: 30px;
|
| 294 |
+
}
|
| 295 |
+
|
| 296 |
+
#question-text {
|
| 297 |
+
font-size: 1.5rem;
|
| 298 |
+
margin-bottom: 20px;
|
| 299 |
+
color: rgba(255, 165, 0, 0.9);
|
| 300 |
+
text-align: center;
|
| 301 |
+
}
|
| 302 |
+
|
| 303 |
+
#options-container {
|
| 304 |
+
display: grid;
|
| 305 |
+
grid-template-columns: repeat(2, 1fr);
|
| 306 |
+
gap: 15px;
|
| 307 |
+
margin-bottom: 20px;
|
| 308 |
+
}
|
| 309 |
+
|
| 310 |
+
.option-btn {
|
| 311 |
+
padding: 15px;
|
| 312 |
+
background-color: rgba(255, 140, 0, 0.6);
|
| 313 |
+
color: white;
|
| 314 |
+
border: 2px solid rgba(255, 165, 0, 0.8);
|
| 315 |
+
border-radius: 8px;
|
| 316 |
+
font-size: 1.1rem;
|
| 317 |
+
cursor: pointer;
|
| 318 |
+
transition: all 0.3s;
|
| 319 |
+
text-align: center;
|
| 320 |
+
}
|
| 321 |
+
|
| 322 |
+
.option-btn:hover {
|
| 323 |
+
background-color: rgba(255, 165, 0, 0.8);
|
| 324 |
+
transform: translateY(-3px);
|
| 325 |
+
box-shadow: 0 5px 15px rgba(255, 140, 0, 0.4);
|
| 326 |
+
}
|
| 327 |
+
|
| 328 |
+
.option-btn.correct {
|
| 329 |
+
background-color: rgba(0, 200, 0, 0.8);
|
| 330 |
+
border-color: rgba(0, 255, 0, 0.8);
|
| 331 |
+
}
|
| 332 |
+
|
| 333 |
+
.option-btn.incorrect {
|
| 334 |
+
background-color: rgba(200, 0, 0, 0.8);
|
| 335 |
+
border-color: rgba(255, 0, 0, 0.8);
|
| 336 |
+
}
|
| 337 |
+
|
| 338 |
+
.option-btn.disabled {
|
| 339 |
+
cursor: not-allowed;
|
| 340 |
+
opacity: 0.7;
|
| 341 |
+
}
|
| 342 |
+
|
| 343 |
+
/* 泉水動畫區域 */
|
| 344 |
+
.spring-animation {
|
| 345 |
+
height: 150px;
|
| 346 |
+
margin: 30px 0;
|
| 347 |
+
position: relative;
|
| 348 |
+
overflow: hidden;
|
| 349 |
+
border-radius: 10px;
|
| 350 |
+
background-color: rgba(0, 100, 255, 0.3);
|
| 351 |
+
}
|
| 352 |
+
|
| 353 |
+
.water-ripple {
|
| 354 |
+
position: absolute;
|
| 355 |
+
top: 50%;
|
| 356 |
+
left: 50%;
|
| 357 |
+
transform: translate(-50%, -50%);
|
| 358 |
+
width: 0;
|
| 359 |
+
height: 0;
|
| 360 |
+
border-radius: 50%;
|
| 361 |
+
background-color: rgba(0, 200, 255, 0.6);
|
| 362 |
+
opacity: 0;
|
| 363 |
+
}
|
| 364 |
+
|
| 365 |
+
.water-ripple.animate {
|
| 366 |
+
animation: ripple 2s ease-out;
|
| 367 |
+
}
|
| 368 |
+
|
| 369 |
+
@keyframes ripple {
|
| 370 |
+
0% {
|
| 371 |
+
width: 0;
|
| 372 |
+
height: 0;
|
| 373 |
+
opacity: 0.8;
|
| 374 |
+
}
|
| 375 |
+
100% {
|
| 376 |
+
width: 300px;
|
| 377 |
+
height: 300px;
|
| 378 |
+
opacity: 0;
|
| 379 |
+
}
|
| 380 |
+
}
|
| 381 |
+
|
| 382 |
+
/* 進度條樣式 */
|
| 383 |
+
.progress-container {
|
| 384 |
+
margin-top: 20px;
|
| 385 |
+
}
|
| 386 |
+
|
| 387 |
+
.progress-text {
|
| 388 |
+
text-align: center;
|
| 389 |
+
margin-bottom: 10px;
|
| 390 |
+
font-size: 1.1rem;
|
| 391 |
+
}
|
| 392 |
+
|
| 393 |
+
.progress-bar {
|
| 394 |
+
height: 15px;
|
| 395 |
+
background-color: rgba(255, 255, 255, 0.2);
|
| 396 |
+
border-radius: 10px;
|
| 397 |
+
overflow: hidden;
|
| 398 |
+
}
|
| 399 |
+
|
| 400 |
+
#progress-fill {
|
| 401 |
+
height: 100%;
|
| 402 |
+
background-color: rgba(255, 165, 0, 0.8);
|
| 403 |
+
width: 0%;
|
| 404 |
+
transition: width 0.5s ease;
|
| 405 |
+
}
|
| 406 |
+
|
| 407 |
+
/* 完成訊息樣式 */
|
| 408 |
+
.completion-message {
|
| 409 |
+
text-align: center;
|
| 410 |
+
padding: 20px;
|
| 411 |
+
}
|
| 412 |
+
|
| 413 |
+
.completion-message h2 {
|
| 414 |
+
color: rgba(255, 215, 0, 0.9);
|
| 415 |
+
font-size: 1.8rem;
|
| 416 |
+
margin-bottom: 20px;
|
| 417 |
+
text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
|
| 418 |
+
}
|
| 419 |
+
|
| 420 |
+
.completion-message p {
|
| 421 |
+
margin-bottom: 15px;
|
| 422 |
+
font-size: 1.1rem;
|
| 423 |
+
}
|
| 424 |
+
|
| 425 |
+
.feedback-container {
|
| 426 |
+
text-align: center;
|
| 427 |
+
margin: 20px 0;
|
| 428 |
+
font-size: 1.2rem;
|
| 429 |
+
min-height: 30px;
|
| 430 |
+
}
|
| 431 |
+
|
| 432 |
/* 響應式設計 */
|
| 433 |
@media (max-width: 768px) {
|
| 434 |
.game-title {
|
|
|
|
| 442 |
padding: 15px;
|
| 443 |
}
|
| 444 |
|
| 445 |
+
.prologue-container, .spring-container {
|
| 446 |
padding: 20px;
|
| 447 |
}
|
| 448 |
|
| 449 |
+
.prologue-title, .spring-title {
|
| 450 |
font-size: 1.8rem;
|
| 451 |
}
|
| 452 |
|
| 453 |
+
.prologue-content, .spring-content {
|
| 454 |
font-size: 1rem;
|
| 455 |
}
|
| 456 |
+
|
| 457 |
+
#options-container {
|
| 458 |
+
grid-template-columns: 1fr;
|
| 459 |
+
}
|
| 460 |
+
|
| 461 |
+
.option-btn {
|
| 462 |
+
padding: 12px;
|
| 463 |
+
}
|
| 464 |
+
|
| 465 |
+
#question-text {
|
| 466 |
+
font-size: 1.3rem;
|
| 467 |
+
}
|
| 468 |
}
|
| 469 |
|
| 470 |
@media (max-width: 480px) {
|
|
|
|
| 487 |
padding: 15px;
|
| 488 |
}
|
| 489 |
|
| 490 |
+
.prologue-title, .spring-title {
|
| 491 |
font-size: 1.5rem;
|
| 492 |
}
|
| 493 |
|
|
|
|
| 499 |
.nav-btn {
|
| 500 |
width: 100%;
|
| 501 |
}
|
| 502 |
+
|
| 503 |
+
.spring-animation {
|
| 504 |
+
height: 120px;
|
| 505 |
+
}
|
| 506 |
+
|
| 507 |
+
.completion-message h2 {
|
| 508 |
+
font-size: 1.5rem;
|
| 509 |
+
}
|
| 510 |
}
|