Fix shrine entry seal and post-entry creator finale
Browse filesKeep the courtyard open, align seal collision to the single visible entrance, display creator credits when entering the shrine, then play the hero and monster chase.
README.md
CHANGED
|
@@ -12,10 +12,13 @@ pinned: false
|
|
| 12 |
|
| 13 |
一款以《薩爾達傳說》初代俯視角冒險為靈感、使用原生 HTML Canvas 製作的瀏覽器像素 RPG。走過草地、擊退 Pillbug、收集星火碎片,打開北方神殿並挑戰魔王。
|
| 14 |
|
|
|
|
|
|
|
| 15 |
## 操作
|
| 16 |
|
| 17 |
- 移動:方向鍵或 WASD
|
| 18 |
- 揮劍:Z、空白鍵或 Enter
|
|
|
|
| 19 |
- 手機/平板:使用畫面下方方向鍵與劍按鈕
|
| 20 |
|
| 21 |
## 素材與授權
|
|
|
|
| 12 |
|
| 13 |
一款以《薩爾達傳說》初代俯視角冒險為靈感、使用原生 HTML Canvas 製作的瀏覽器像素 RPG。走過草地、擊退 Pillbug、收集星火碎片,打開北方神殿並挑戰魔王。
|
| 14 |
|
| 15 |
+
神殿封印只擋在門口,不影響外面的廣場。收齊五枚星火碎片擊敗魔王後,走進敞開的大門;遊戲會先顯示 **HelloSun** 和 **GPT-6_Luna** 的製作名單,再播放勇者被三隻森林魔物追逐的動畫。
|
| 16 |
+
|
| 17 |
## 操作
|
| 18 |
|
| 19 |
- 移動:方向鍵或 WASD
|
| 20 |
- 揮劍:Z、空白鍵或 Enter
|
| 21 |
+
- 擊敗魔王後走進神殿,觀看製作名單與追逐動畫;按「再玩一次」重新冒險
|
| 22 |
- 手機/平板:使用畫面下方方向鍵與劍按鈕
|
| 23 |
|
| 24 |
## 素材與授權
|
game.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
| 11 |
const WORLD_W = MAP_W * TILE;
|
| 12 |
const WORLD_H = MAP_H * TILE;
|
| 13 |
const LAKE = { x: 20.5 * TILE, y: 25 * TILE, rx: 3.25 * TILE, ry: 2.05 * TILE };
|
|
|
|
| 14 |
const view = { w: canvas.width, h: canvas.height };
|
| 15 |
const keys = new Set();
|
| 16 |
const image = (src) => { const img = new Image(); img.src = src; return img; };
|
|
@@ -206,14 +207,9 @@
|
|
| 206 |
}
|
| 207 |
}
|
| 208 |
|
| 209 |
-
//
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
if (x === 18 || x === 31 || y === 7 || y === 10) {
|
| 213 |
-
if (!(x >= 23 && x <= 26 && y === 10)) obstacles.push({ x, y, type: 'temple' });
|
| 214 |
-
}
|
| 215 |
-
}
|
| 216 |
-
}
|
| 217 |
|
| 218 |
const reserved = (x, y) => (x >= 15 && x <= 34 && y >= 2 && y <= 12)
|
| 219 |
|| (x >= 21 && x <= 29 && y >= 26 && y <= 33)
|
|
@@ -246,6 +242,12 @@
|
|
| 246 |
shards: 0,
|
| 247 |
boss: null,
|
| 248 |
bossDefeated: false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 249 |
started: false,
|
| 250 |
won: false,
|
| 251 |
time: 0,
|
|
@@ -261,7 +263,9 @@
|
|
| 261 |
}
|
| 262 |
|
| 263 |
function updateObjective() {
|
| 264 |
-
if (state.
|
|
|
|
|
|
|
| 265 |
else if (state.boss) objectiveEl.textContent = `擊敗神殿魔王 · ${'♥'.repeat(Math.max(0, state.boss.hp))}${'♡'.repeat(Math.max(0, state.boss.maxHp - state.boss.hp))}`;
|
| 266 |
else objectiveEl.textContent = `找到星火碎片 · ${state.shards} / 5`;
|
| 267 |
}
|
|
@@ -275,16 +279,55 @@
|
|
| 275 |
}
|
| 276 |
|
| 277 |
function showEnd() {
|
|
|
|
| 278 |
state.won = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 279 |
intro.classList.remove('hidden');
|
| 280 |
-
|
| 281 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 282 |
}
|
| 283 |
|
| 284 |
function isSolid(x, y) {
|
| 285 |
const tx = Math.floor(x / TILE);
|
| 286 |
const ty = Math.floor(y / TILE);
|
| 287 |
-
return state.obstacles.some((o) =>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 288 |
}
|
| 289 |
|
| 290 |
function isLake(x, y) {
|
|
@@ -313,7 +356,7 @@
|
|
| 313 |
}
|
| 314 |
|
| 315 |
function sword() {
|
| 316 |
-
if (!state.started || state.won || swingTimer > .1) return;
|
| 317 |
swingTimer = .32;
|
| 318 |
const p = state.player;
|
| 319 |
const diagonal = Math.SQRT1_2;
|
|
@@ -341,9 +384,8 @@
|
|
| 341 |
state.bossDefeated = true;
|
| 342 |
state.boss = null;
|
| 343 |
burst(enemy.x, enemy.y, '#ffd879', 46);
|
| 344 |
-
say('魔王化作星塵
|
| 345 |
updateObjective();
|
| 346 |
-
window.setTimeout(showEnd, 2000);
|
| 347 |
} else {
|
| 348 |
enemy.alive = false;
|
| 349 |
state.drops.push({ x: enemy.x, y: enemy.y, life: 18, kind: 'shard' });
|
|
@@ -368,11 +410,16 @@
|
|
| 368 |
}
|
| 369 |
|
| 370 |
function summonBoss() {
|
| 371 |
-
state.boss = { x:
|
| 372 |
say('古老的封印裂開了……熔岩之王甦醒!', 3.2);
|
| 373 |
updateObjective();
|
| 374 |
}
|
| 375 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 376 |
function moveEnemy(enemy, dt) {
|
| 377 |
if (!enemy.alive || enemy.boss) return;
|
| 378 |
enemy.flash = Math.max(0, (enemy.flash || 0) - dt);
|
|
@@ -428,6 +475,61 @@
|
|
| 428 |
}
|
| 429 |
|
| 430 |
function update(dt) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 431 |
if (!state.started || state.won) return;
|
| 432 |
state.time += dt;
|
| 433 |
const p = state.player;
|
|
@@ -488,10 +590,16 @@
|
|
| 488 |
}
|
| 489 |
state.particles = state.particles.filter((p) => p.life > 0);
|
| 490 |
|
| 491 |
-
const
|
| 492 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 493 |
if (state.shards >= 5) summonBoss();
|
| 494 |
-
else if (toastTimer <= 0) say(`神殿
|
| 495 |
}
|
| 496 |
updateObjective();
|
| 497 |
}
|
|
@@ -548,11 +656,33 @@
|
|
| 548 |
ctx.fillStyle = '#c0b18a'; ctx.fillRect(x + 12 + i * 63, y + 60, 5, 67);
|
| 549 |
}
|
| 550 |
ctx.fillStyle = '#413d32'; ctx.fillRect(x + 5, y + 125, tx.w * TILE - 10, 12);
|
| 551 |
-
|
| 552 |
-
|
| 553 |
-
|
| 554 |
-
|
| 555 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 556 |
}
|
| 557 |
ctx.fillStyle = '#ddd0a7'; ctx.fillRect(x - 13, y + 134, tx.w * TILE + 26, 5);
|
| 558 |
}
|
|
@@ -612,8 +742,73 @@
|
|
| 612 |
}
|
| 613 |
}
|
| 614 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 615 |
function draw(camX, camY) {
|
| 616 |
drawGround(camX, camY);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 617 |
const objects = [];
|
| 618 |
for (const prop of state.props) objects.push({ y: (prop.y + .8) * TILE, draw: () => prop.type === 'tree' ? drawTree(prop.x, prop.y, prop.variant, camX, camY) : drawRock(prop.x, prop.y, camX, camY) });
|
| 619 |
const tx = state.temple;
|
|
@@ -688,6 +883,13 @@
|
|
| 688 |
}
|
| 689 |
|
| 690 |
window.addEventListener('keydown', (event) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 691 |
if (['ArrowUp','ArrowDown','ArrowLeft','ArrowRight','Space'].includes(event.code)) event.preventDefault();
|
| 692 |
keys.add(event.code);
|
| 693 |
if (event.code === 'KeyZ' || event.code === 'Space' || event.code === 'Enter') sword();
|
|
@@ -695,6 +897,18 @@
|
|
| 695 |
});
|
| 696 |
window.addEventListener('keyup', (event) => keys.delete(event.code));
|
| 697 |
window.addEventListener('blur', () => keys.clear());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 698 |
document.querySelector('#start').addEventListener('click', start);
|
| 699 |
document.querySelector('#restart').addEventListener('click', () => {
|
| 700 |
reset();
|
|
|
|
| 11 |
const WORLD_W = MAP_W * TILE;
|
| 12 |
const WORLD_H = MAP_H * TILE;
|
| 13 |
const LAKE = { x: 20.5 * TILE, y: 25 * TILE, rx: 3.25 * TILE, ry: 2.05 * TILE };
|
| 14 |
+
const SHRINE_DOOR = { x: 25 * TILE, top: 5 * TILE, width: 2 * TILE };
|
| 15 |
const view = { w: canvas.width, h: canvas.height };
|
| 16 |
const keys = new Set();
|
| 17 |
const image = (src) => { const img = new Image(); img.src = src; return img; };
|
|
|
|
| 207 |
}
|
| 208 |
}
|
| 209 |
|
| 210 |
+
// One collision tile covers the actual doorway, not the surrounding courtyard.
|
| 211 |
+
obstacles.push({ x: 24, y: Math.floor(SHRINE_DOOR.top / TILE), type: 'seal' });
|
| 212 |
+
obstacles.push({ x: 25, y: Math.floor(SHRINE_DOOR.top / TILE), type: 'seal' });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 213 |
|
| 214 |
const reserved = (x, y) => (x >= 15 && x <= 34 && y >= 2 && y <= 12)
|
| 215 |
|| (x >= 21 && x <= 29 && y >= 26 && y <= 33)
|
|
|
|
| 242 |
shards: 0,
|
| 243 |
boss: null,
|
| 244 |
bossDefeated: false,
|
| 245 |
+
ending: false,
|
| 246 |
+
endingTime: 0,
|
| 247 |
+
endingStage: '',
|
| 248 |
+
creditsShown: false,
|
| 249 |
+
chase: [],
|
| 250 |
+
chaseSparkTimer: 0,
|
| 251 |
started: false,
|
| 252 |
won: false,
|
| 253 |
time: 0,
|
|
|
|
| 263 |
}
|
| 264 |
|
| 265 |
function updateObjective() {
|
| 266 |
+
if (state.creditsShown) objectiveEl.textContent = '謝謝你和我們一起完成這場冒險。';
|
| 267 |
+
else if (state.ending) objectiveEl.textContent = '勇者和魔物的最後一場追逐!';
|
| 268 |
+
else if (state.bossDefeated) objectiveEl.textContent = '魔王已敗,走進敞開的神殿大門。';
|
| 269 |
else if (state.boss) objectiveEl.textContent = `擊敗神殿魔王 · ${'♥'.repeat(Math.max(0, state.boss.hp))}${'♡'.repeat(Math.max(0, state.boss.maxHp - state.boss.hp))}`;
|
| 270 |
else objectiveEl.textContent = `找到星火碎片 · ${state.shards} / 5`;
|
| 271 |
}
|
|
|
|
| 279 |
}
|
| 280 |
|
| 281 |
function showEnd() {
|
| 282 |
+
if (state.ending) return;
|
| 283 |
state.won = true;
|
| 284 |
+
state.ending = true;
|
| 285 |
+
state.endingTime = 0;
|
| 286 |
+
state.endingStage = 'opening-credits';
|
| 287 |
+
state.creditsShown = false;
|
| 288 |
+
state.chaseSparkTimer = 0;
|
| 289 |
+
toast = '';
|
| 290 |
+
toastTimer = 0;
|
| 291 |
+
keys.clear();
|
| 292 |
+
state.player.x = SHRINE_DOOR.x;
|
| 293 |
+
state.player.y = SHRINE_DOOR.top - 20;
|
| 294 |
+
state.player.facing = 'right';
|
| 295 |
+
state.chase = [
|
| 296 |
+
{ id: 1, x: state.player.x - 72, y: state.player.y + 40, phase: 1, alive: true, hp: 1, flash: 0 },
|
| 297 |
+
{ id: 2, x: state.player.x - 145, y: state.player.y - 29, phase: 2, alive: true, hp: 1, flash: 0 },
|
| 298 |
+
{ id: 3, x: state.player.x - 218, y: state.player.y + 57, phase: 3, alive: true, hp: 1, flash: 0 },
|
| 299 |
+
];
|
| 300 |
+
state.chaseSparkTimer = 0;
|
| 301 |
+
intro.innerHTML = '<div class="title-card credits-card"><div class="title-eyebrow">THE PEOPLE OF STARFIRE FOREST</div><h1>星火之森</h1><p>古老封印再度閃耀……</p><div class="credits-list"><span>作者</span><strong>HelloSun</strong><span>協作</span><strong>GPT-6_Luna</strong></div><div class="title-hint">神殿深處傳來急促的腳步聲</div></div>';
|
| 302 |
intro.classList.remove('hidden');
|
| 303 |
+
updateObjective();
|
| 304 |
+
}
|
| 305 |
+
|
| 306 |
+
function showCredits() {
|
| 307 |
+
state.creditsShown = true;
|
| 308 |
+
state.endingStage = 'done';
|
| 309 |
+
intro.innerHTML = '<div class="title-card credits-card"><div class="title-eyebrow">THE PEOPLE OF STARFIRE FOREST</div><h1>星火之森</h1><p>勇者成功逃離魔物追逐,謝謝你完成冒險!</p><div class="credits-list"><span>作者</span><strong>HelloSun</strong><span>協作</span><strong>GPT-6_Luna</strong></div><button id="start" class="start-button" type="button"><span>✦</span> 再玩一次 <span>✦</span></button><div class="title-hint">THANK YOU FOR PLAYING</div></div>';
|
| 310 |
+
intro.classList.remove('hidden');
|
| 311 |
+
intro.querySelector('#start').addEventListener('click', () => {
|
| 312 |
+
reset();
|
| 313 |
+
showIntro();
|
| 314 |
+
intro.classList.remove('hidden');
|
| 315 |
+
});
|
| 316 |
+
updateObjective();
|
| 317 |
}
|
| 318 |
|
| 319 |
function isSolid(x, y) {
|
| 320 |
const tx = Math.floor(x / TILE);
|
| 321 |
const ty = Math.floor(y / TILE);
|
| 322 |
+
return state.obstacles.some((o) => {
|
| 323 |
+
if (o.x !== tx || o.y !== ty) return false;
|
| 324 |
+
if (o.type !== 'seal') return true;
|
| 325 |
+
if (state.bossDefeated) return false;
|
| 326 |
+
// Only the narrow doorway arch is sealed; the rest of the same map tile
|
| 327 |
+
// is walkable along the temple facade.
|
| 328 |
+
return Math.abs(x - SHRINE_DOOR.x) < SHRINE_DOOR.width / 2
|
| 329 |
+
&& y >= SHRINE_DOOR.top - 4 && y < SHRINE_DOOR.top + 38;
|
| 330 |
+
});
|
| 331 |
}
|
| 332 |
|
| 333 |
function isLake(x, y) {
|
|
|
|
| 356 |
}
|
| 357 |
|
| 358 |
function sword() {
|
| 359 |
+
if (!state.started || state.won || state.ending || swingTimer > .1) return;
|
| 360 |
swingTimer = .32;
|
| 361 |
const p = state.player;
|
| 362 |
const diagonal = Math.SQRT1_2;
|
|
|
|
| 384 |
state.bossDefeated = true;
|
| 385 |
state.boss = null;
|
| 386 |
burst(enemy.x, enemy.y, '#ffd879', 46);
|
| 387 |
+
say('魔王化作星塵!只有大門封印解除了,走進神殿看看吧。', 4.2);
|
| 388 |
updateObjective();
|
|
|
|
| 389 |
} else {
|
| 390 |
enemy.alive = false;
|
| 391 |
state.drops.push({ x: enemy.x, y: enemy.y, life: 18, kind: 'shard' });
|
|
|
|
| 410 |
}
|
| 411 |
|
| 412 |
function summonBoss() {
|
| 413 |
+
state.boss = { x: SHRINE_DOOR.x, y: 7.15 * TILE, hp: 12, maxHp: 12, boss: true, alive: true, flash: 0, attackTimer: 1.4, phase: 0, radius: 35 };
|
| 414 |
say('古老的封印裂開了……熔岩之王甦醒!', 3.2);
|
| 415 |
updateObjective();
|
| 416 |
}
|
| 417 |
|
| 418 |
+
function tickEnding(seconds) {
|
| 419 |
+
const duration = Math.max(.001, seconds);
|
| 420 |
+
for (let i = 0; i < 1000; i++) update(duration / 1000);
|
| 421 |
+
}
|
| 422 |
+
|
| 423 |
function moveEnemy(enemy, dt) {
|
| 424 |
if (!enemy.alive || enemy.boss) return;
|
| 425 |
enemy.flash = Math.max(0, (enemy.flash || 0) - dt);
|
|
|
|
| 475 |
}
|
| 476 |
|
| 477 |
function update(dt) {
|
| 478 |
+
if (state.ending) {
|
| 479 |
+
state.endingTime += dt;
|
| 480 |
+
if (state.endingStage === 'opening-credits') {
|
| 481 |
+
if (state.endingTime >= 2.4) {
|
| 482 |
+
state.endingStage = 'chase';
|
| 483 |
+
state.endingTime = 0;
|
| 484 |
+
state.player.x = SHRINE_DOOR.x;
|
| 485 |
+
state.player.y = SHRINE_DOOR.top - 24;
|
| 486 |
+
intro.classList.add('hidden');
|
| 487 |
+
updateObjective();
|
| 488 |
+
}
|
| 489 |
+
return;
|
| 490 |
+
}
|
| 491 |
+
if (state.endingStage === 'done') return;
|
| 492 |
+
const time = state.endingTime;
|
| 493 |
+
const p = state.player;
|
| 494 |
+
const centerX = SHRINE_DOOR.x;
|
| 495 |
+
// Race loops around the interior nave after crossing the visible door.
|
| 496 |
+
const centerY = SHRINE_DOOR.top - 31;
|
| 497 |
+
const lap = time * .84;
|
| 498 |
+
const previousX = p.x, previousY = p.y;
|
| 499 |
+
p.x = centerX + Math.cos(lap) * 63;
|
| 500 |
+
p.y = centerY + Math.sin(lap * 2) * 10;
|
| 501 |
+
const dxWalk = p.x - previousX, dyWalk = p.y - previousY;
|
| 502 |
+
p.walk += dt * 18;
|
| 503 |
+
if (Math.abs(dxWalk) > Math.abs(dyWalk) * 1.7) p.facing = dxWalk > 0 ? 'right' : 'left';
|
| 504 |
+
else if (Math.abs(dyWalk) > Math.abs(dxWalk) * 1.7) p.facing = dyWalk > 0 ? 'down' : 'up';
|
| 505 |
+
else p.facing = dyWalk > 0 ? (dxWalk > 0 ? 'down-right' : 'down-left') : (dxWalk > 0 ? 'up-right' : 'up-left');
|
| 506 |
+
const pace = Math.hypot(dxWalk, dyWalk);
|
| 507 |
+
if (pace > 1) state.chaseSparkTimer -= dt;
|
| 508 |
+
if (state.chaseSparkTimer <= 0 && pace > 1) {
|
| 509 |
+
state.chaseSparkTimer = .13;
|
| 510 |
+
state.particles.push({ x: previousX, y: previousY + 8, vx: (random() - .5) * 12, vy: -14, life: .3, maxLife: .3, color: '#f1d98a', size: 2 });
|
| 511 |
+
}
|
| 512 |
+
for (const enemy of state.chase) {
|
| 513 |
+
enemy.phase += dt * 11;
|
| 514 |
+
const dx = p.x - enemy.x, dy = p.y - enemy.y;
|
| 515 |
+
const length = Math.max(1, Math.hypot(dx, dy));
|
| 516 |
+
const speed = (31 + enemy.id * 4) * dt;
|
| 517 |
+
const curl = enemy.id % 2 ? -12 : 12;
|
| 518 |
+
enemy.x += dx / length * speed - dy / length * curl * dt;
|
| 519 |
+
enemy.y += dy / length * speed + dx / length * curl * dt + Math.sin(enemy.phase) * 9 * dt;
|
| 520 |
+
}
|
| 521 |
+
for (const particle of state.particles) {
|
| 522 |
+
particle.x += particle.vx * dt;
|
| 523 |
+
particle.y += particle.vy * dt;
|
| 524 |
+
particle.life -= dt;
|
| 525 |
+
}
|
| 526 |
+
state.particles = state.particles.filter((particle) => particle.life > 0);
|
| 527 |
+
if (time >= 7.2 && !state.creditsShown) {
|
| 528 |
+
showCredits();
|
| 529 |
+
state.endingStage = 'done';
|
| 530 |
+
}
|
| 531 |
+
return;
|
| 532 |
+
}
|
| 533 |
if (!state.started || state.won) return;
|
| 534 |
state.time += dt;
|
| 535 |
const p = state.player;
|
|
|
|
| 590 |
}
|
| 591 |
state.particles = state.particles.filter((p) => p.life > 0);
|
| 592 |
|
| 593 |
+
const centeredOnDoor = Math.abs(p.x - SHRINE_DOOR.x) < SHRINE_DOOR.width * .5;
|
| 594 |
+
const insideShrine = centeredOnDoor && p.y < SHRINE_DOOR.top - 28 && p.y > SHRINE_DOOR.top - 190;
|
| 595 |
+
// Unlock triggers only when the player reaches the sealed arch itself.
|
| 596 |
+
const atDoorThreshold = centeredOnDoor && p.y >= SHRINE_DOOR.top + 24 && p.y <= SHRINE_DOOR.top + 84;
|
| 597 |
+
if (state.bossDefeated && !state.ending && insideShrine) {
|
| 598 |
+
showEnd();
|
| 599 |
+
tickEnding(.24);
|
| 600 |
+
} else if (atDoorThreshold && !state.bossDefeated && !state.boss) {
|
| 601 |
if (state.shards >= 5) summonBoss();
|
| 602 |
+
else if (toastTimer <= 0) say(`只有神殿入口有封印,需要星火碎片 ${state.shards} / 5`, 2.5);
|
| 603 |
}
|
| 604 |
updateObjective();
|
| 605 |
}
|
|
|
|
| 656 |
ctx.fillStyle = '#c0b18a'; ctx.fillRect(x + 12 + i * 63, y + 60, 5, 67);
|
| 657 |
}
|
| 658 |
ctx.fillStyle = '#413d32'; ctx.fillRect(x + 5, y + 125, tx.w * TILE - 10, 12);
|
| 659 |
+
const doorX = SHRINE_DOOR.x - camX;
|
| 660 |
+
const doorTop = SHRINE_DOOR.top - camY;
|
| 661 |
+
const doorLeft = doorX - SHRINE_DOOR.width / 2;
|
| 662 |
+
ctx.fillStyle = '#413d32'; ctx.fillRect(doorLeft - 8, doorTop - 15, SHRINE_DOOR.width + 16, 59);
|
| 663 |
+
ctx.fillStyle = '#b8a57b'; ctx.fillRect(doorLeft - 6, doorTop - 11, 4, 54);
|
| 664 |
+
ctx.fillStyle = '#4b4937'; ctx.fillRect(doorLeft + SHRINE_DOOR.width + 2, doorTop - 11, 4, 54);
|
| 665 |
+
ctx.fillStyle = '#d0bb89'; ctx.fillRect(doorLeft - 9, doorTop - 15, SHRINE_DOOR.width + 18, 5);
|
| 666 |
+
if (!state.bossDefeated) {
|
| 667 |
+
// The seal covers only the actual archway, leaving the rest of the
|
| 668 |
+
// temple façade, landing, and courtyard fully open to the player.
|
| 669 |
+
ctx.fillStyle = '#191c19'; ctx.fillRect(doorLeft, doorTop, SHRINE_DOOR.width, 40);
|
| 670 |
+
ctx.fillStyle = state.shards >= 5 ? '#e3bd70' : '#89513b';
|
| 671 |
+
ctx.fillRect(doorLeft + 20, doorTop + 9, 10, 25);
|
| 672 |
+
ctx.fillStyle = state.shards >= 5 ? '#ffe6a0' : '#d2a363';
|
| 673 |
+
ctx.fillRect(doorLeft + 16, doorTop + 15, 18, 15);
|
| 674 |
+
ctx.fillStyle = '#382c24'; ctx.fillRect(doorLeft + 22, doorTop + 17, 6, 6);
|
| 675 |
+
if (state.shards >= 5) {
|
| 676 |
+
ctx.strokeStyle = '#ffe39b'; ctx.globalAlpha = .4 + Math.sin(state.time * 3) * .2;
|
| 677 |
+
ctx.lineWidth = 2; ctx.strokeRect(doorLeft - 3, doorTop - 3, SHRINE_DOOR.width + 6, 45); ctx.globalAlpha = 1;
|
| 678 |
+
}
|
| 679 |
+
} else {
|
| 680 |
+
const welcome = ctx.createRadialGradient(doorX, doorTop + 20, 2, doorX, doorTop + 20, 54);
|
| 681 |
+
welcome.addColorStop(0, '#ffe7a8e8'); welcome.addColorStop(.4, '#d4ab687a'); welcome.addColorStop(1, '#d4ab6800');
|
| 682 |
+
ctx.fillStyle = welcome; ctx.fillRect(doorLeft - 28, doorTop - 28, SHRINE_DOOR.width + 56, 96);
|
| 683 |
+
ctx.fillStyle = '#101815'; ctx.fillRect(doorLeft, doorTop, SHRINE_DOOR.width, 40);
|
| 684 |
+
ctx.fillStyle = '#beab7d'; ctx.fillRect(doorLeft - 4, doorTop - 6, 5, 49); ctx.fillRect(doorLeft + SHRINE_DOOR.width - 1, doorTop - 6, 5, 49);
|
| 685 |
+
ctx.fillStyle = '#dfcb99'; ctx.fillRect(doorLeft - 5, doorTop - 7, SHRINE_DOOR.width + 10, 4);
|
| 686 |
}
|
| 687 |
ctx.fillStyle = '#ddd0a7'; ctx.fillRect(x - 13, y + 134, tx.w * TILE + 26, 5);
|
| 688 |
}
|
|
|
|
| 742 |
}
|
| 743 |
}
|
| 744 |
|
| 745 |
+
function drawChaseBug(enemy, camX, camY) {
|
| 746 |
+
const x = Math.round(enemy.x - camX);
|
| 747 |
+
const y = Math.round(enemy.y - camY + Math.sin(enemy.phase) * 2.5);
|
| 748 |
+
ctx.fillStyle = '#15201685';
|
| 749 |
+
ctx.beginPath(); ctx.ellipse(x, y + 12, 15, 5, 0, 0, Math.PI * 2); ctx.fill();
|
| 750 |
+
if (sprites.bug.complete && sprites.bug.naturalWidth) {
|
| 751 |
+
const frame = Math.floor(state.endingTime * 11 + enemy.id) % 6;
|
| 752 |
+
ctx.drawImage(sprites.bug, frame * 32, 0, 32, 32, x - 19, y - 19, 38, 38);
|
| 753 |
+
} else {
|
| 754 |
+
ctx.fillStyle = '#b8c978';
|
| 755 |
+
ctx.beginPath(); ctx.ellipse(x, y, 14, 10, 0, 0, Math.PI * 2); ctx.fill();
|
| 756 |
+
}
|
| 757 |
+
ctx.fillStyle = '#f4d37c'; ctx.globalAlpha = Math.min(1, Math.max(0, enemy.phase % 1));
|
| 758 |
+
ctx.fillRect(x - 2, y - 2, 3, 3); ctx.globalAlpha = 1;
|
| 759 |
+
}
|
| 760 |
+
|
| 761 |
function draw(camX, camY) {
|
| 762 |
drawGround(camX, camY);
|
| 763 |
+
if (state.ending) {
|
| 764 |
+
const titleX = view.w / 2, titleY = view.h * .32;
|
| 765 |
+
const float = Math.sin(state.endingTime * 2.4) * 4;
|
| 766 |
+
ctx.fillStyle = '#18251ce8'; ctx.beginPath(); ctx.roundRect(titleX - 205, titleY - 34, 410, 69, 14); ctx.fill();
|
| 767 |
+
ctx.strokeStyle = '#e9d59362'; ctx.lineWidth = 1; ctx.stroke();
|
| 768 |
+
ctx.textAlign = 'center'; ctx.fillStyle = '#e6cf93'; ctx.font = '11px "DM Mono", monospace';
|
| 769 |
+
ctx.fillText('THE LAST CHASE', titleX, titleY - 8 + float);
|
| 770 |
+
ctx.fillStyle = '#f5e6ba'; ctx.font = '15px "Noto Sans TC", sans-serif';
|
| 771 |
+
ctx.fillText(state.creditsShown ? '神殿製作名單' : '勇者與魔物的森林大追逐!', titleX, titleY + 18 + float);
|
| 772 |
+
ctx.textAlign = 'start';
|
| 773 |
+
if (!state.creditsShown) {
|
| 774 |
+
for (const bug of state.chase) drawChaseBug(bug, camX, camY);
|
| 775 |
+
drawHero(camX, camY);
|
| 776 |
+
}
|
| 777 |
+
for (const particle of state.creditsShown ? [] : state.particles) {
|
| 778 |
+
ctx.globalAlpha = Math.max(0, particle.life / particle.maxLife);
|
| 779 |
+
ctx.fillStyle = particle.color;
|
| 780 |
+
ctx.fillRect(Math.round(particle.x - camX), Math.round(particle.y - camY), particle.size, particle.size);
|
| 781 |
+
}
|
| 782 |
+
ctx.globalAlpha = 1;
|
| 783 |
+
if (state.creditsShown) {
|
| 784 |
+
const fade = Math.min(1, (state.endingTime - 8) * .8);
|
| 785 |
+
ctx.globalAlpha = fade;
|
| 786 |
+
const panelX = view.w / 2 - 185, panelY = titleY + 54;
|
| 787 |
+
ctx.fillStyle = '#17241df2'; ctx.beginPath(); ctx.roundRect(panelX, panelY, 370, 134, 12); ctx.fill();
|
| 788 |
+
ctx.strokeStyle = '#e9ddb34d'; ctx.stroke();
|
| 789 |
+
ctx.textAlign = 'center'; ctx.fillStyle = '#aeb99e'; ctx.font = '11px "DM Mono", monospace';
|
| 790 |
+
ctx.fillText('PRODUCTION CREDITS', view.w / 2, panelY + 25);
|
| 791 |
+
ctx.fillStyle = '#d3d5c1'; ctx.font = '12px "Noto Sans TC", sans-serif'; ctx.fillText('作者', view.w / 2, panelY + 53);
|
| 792 |
+
ctx.fillStyle = '#f4dfa0'; ctx.font = 'bold 20px "DM Mono", monospace'; ctx.fillText('HelloSun', view.w / 2, panelY + 78);
|
| 793 |
+
ctx.fillStyle = '#d3d5c1'; ctx.font = '12px "Noto Sans TC", sans-serif'; ctx.fillText('協作', view.w / 2, panelY + 105);
|
| 794 |
+
ctx.fillStyle = '#f4dfa0'; ctx.font = 'bold 18px "DM Mono", monospace'; ctx.fillText('GPT-6_Luna', view.w / 2, panelY + 128);
|
| 795 |
+
ctx.textAlign = 'start'; ctx.globalAlpha = 1;
|
| 796 |
+
const restartX = view.w / 2 - 64, restartY = panelY + 151;
|
| 797 |
+
ctx.fillStyle = '#17241df2'; ctx.beginPath(); ctx.roundRect(restartX, restartY, 128, 34, 7); ctx.fill();
|
| 798 |
+
ctx.strokeStyle = '#e9ddb34d'; ctx.stroke(); ctx.fillStyle = '#e6cf93'; ctx.font = '12px "Noto Sans TC", sans-serif';
|
| 799 |
+
ctx.textAlign = 'center'; ctx.fillText('重新開始 ↺', view.w / 2, restartY + 22); ctx.textAlign = 'start';
|
| 800 |
+
state.restartBounds = { x: restartX, y: restartY, w: 128, h: 34 };
|
| 801 |
+
} else if (state.endingTime > 6.1) {
|
| 802 |
+
const fade = Math.min(1, (state.endingTime - 6.1) * .48);
|
| 803 |
+
ctx.globalAlpha = fade;
|
| 804 |
+
ctx.fillStyle = '#17241dd9'; ctx.beginPath(); ctx.roundRect(view.w / 2 - 112, view.h - 77, 224, 35, 8); ctx.fill();
|
| 805 |
+
ctx.fillStyle = '#f2e5bd'; ctx.font = '13px "Noto Sans TC", sans-serif';
|
| 806 |
+
ctx.textAlign = 'center'; ctx.fillText('進入神殿查看製作名單', view.w / 2, view.h - 55); ctx.textAlign = 'start';
|
| 807 |
+
ctx.globalAlpha = 1;
|
| 808 |
+
}
|
| 809 |
+
drawHud(camX, camY);
|
| 810 |
+
return;
|
| 811 |
+
}
|
| 812 |
const objects = [];
|
| 813 |
for (const prop of state.props) objects.push({ y: (prop.y + .8) * TILE, draw: () => prop.type === 'tree' ? drawTree(prop.x, prop.y, prop.variant, camX, camY) : drawRock(prop.x, prop.y, camX, camY) });
|
| 814 |
const tx = state.temple;
|
|
|
|
| 883 |
}
|
| 884 |
|
| 885 |
window.addEventListener('keydown', (event) => {
|
| 886 |
+
if (state.creditsShown && ['Enter', 'Space', 'KeyZ'].includes(event.code)) {
|
| 887 |
+
event.preventDefault();
|
| 888 |
+
reset();
|
| 889 |
+
showIntro();
|
| 890 |
+
intro.classList.remove('hidden');
|
| 891 |
+
return;
|
| 892 |
+
}
|
| 893 |
if (['ArrowUp','ArrowDown','ArrowLeft','ArrowRight','Space'].includes(event.code)) event.preventDefault();
|
| 894 |
keys.add(event.code);
|
| 895 |
if (event.code === 'KeyZ' || event.code === 'Space' || event.code === 'Enter') sword();
|
|
|
|
| 897 |
});
|
| 898 |
window.addEventListener('keyup', (event) => keys.delete(event.code));
|
| 899 |
window.addEventListener('blur', () => keys.clear());
|
| 900 |
+
canvas.addEventListener('pointerdown', (event) => {
|
| 901 |
+
if (!state.creditsShown || !state.restartBounds) return;
|
| 902 |
+
const rect = canvas.getBoundingClientRect();
|
| 903 |
+
const x = (event.clientX - rect.left) * canvas.width / rect.width;
|
| 904 |
+
const y = (event.clientY - rect.top) * canvas.height / rect.height;
|
| 905 |
+
const button = state.restartBounds;
|
| 906 |
+
if (x >= button.x && x <= button.x + button.w && y >= button.y && y <= button.y + button.h) {
|
| 907 |
+
reset();
|
| 908 |
+
showIntro();
|
| 909 |
+
intro.classList.remove('hidden');
|
| 910 |
+
}
|
| 911 |
+
});
|
| 912 |
document.querySelector('#start').addEventListener('click', start);
|
| 913 |
document.querySelector('#restart').addEventListener('click', () => {
|
| 914 |
reset();
|
index.html
CHANGED
|
@@ -43,7 +43,7 @@
|
|
| 43 |
<div class="legend"><span class="legend-spark">✦</span><span id="objective">踏上旅程,收集 5 個星火碎片</span></div>
|
| 44 |
<div class="controls-hint"><kbd>W</kbd><kbd>A</kbd><kbd>S</kbd><kbd>D</kbd> 或 <kbd>↑</kbd><kbd>←</kbd><kbd>↓</kbd><kbd>→</kbd><span class="hint-separator"></span><kbd>Z</kbd> 揮劍</div>
|
| 45 |
</section>
|
| 46 |
-
<footer>遊戲
|
| 47 |
</main>
|
| 48 |
<script src="game.js" defer></script>
|
| 49 |
</body>
|
|
|
|
| 43 |
<div class="legend"><span class="legend-spark">✦</span><span id="objective">踏上旅程,收集 5 個星火碎片</span></div>
|
| 44 |
<div class="controls-hint"><kbd>W</kbd><kbd>A</kbd><kbd>S</kbd><kbd>D</kbd> 或 <kbd>↑</kbd><kbd>←</kbd><kbd>↓</kbd><kbd>→</kbd><span class="hint-separator"></span><kbd>Z</kbd> 揮劍</div>
|
| 45 |
</section>
|
| 46 |
+
<footer>本遊戲作者:<strong>HelloSun</strong> · 協作:<strong>GPT-6_Luna</strong> · 遊戲程式採 AGPL-3.0-or-later · 角色與像素素材依 KLPL 1.0 授權 · <a href="KLPL.md" target="_blank">素材授權與來源</a></footer>
|
| 47 |
</main>
|
| 48 |
<script src="game.js" defer></script>
|
| 49 |
</body>
|
style.css
CHANGED
|
@@ -4,3 +4,10 @@
|
|
| 4 |
@media(pointer:coarse){.touch-controls{display:flex}.screen-wrap{touch-action:none}}
|
| 5 |
@media(max-width:480px){body{padding:8px}.chapter{max-width:130px;text-align:center}.bottom-bar{min-height:39px}.legend{font-size:10px}footer{padding-top:10px}.title-eyebrow{font-size:9px}.touch-controls{padding-inline:11px}}
|
| 6 |
@media(min-width:651px){.touch-controls{display:none!important}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
@media(pointer:coarse){.touch-controls{display:flex}.screen-wrap{touch-action:none}}
|
| 5 |
@media(max-width:480px){body{padding:8px}.chapter{max-width:130px;text-align:center}.bottom-bar{min-height:39px}.legend{font-size:10px}footer{padding-top:10px}.title-eyebrow{font-size:9px}.touch-controls{padding-inline:11px}}
|
| 6 |
@media(min-width:651px){.touch-controls{display:none!important}}
|
| 7 |
+
|
| 8 |
+
/* The late-game producer card keeps both credit lines together on phones. */
|
| 9 |
+
.credits-card{width:min(430px,88%);padding:27px 26px 22px}
|
| 10 |
+
.credits-card h1{margin:9px 0 6px;font-size:clamp(31px,5vw,46px)}
|
| 11 |
+
.credits-card p{margin-bottom:12px;font-size:12px}
|
| 12 |
+
.credits-list{display:grid;grid-template-columns:1fr;gap:2px;margin:12px auto 17px;color:#aebaa0;font-size:12px}
|
| 13 |
+
.credits-list strong{margin-bottom:7px;color:#f2d991;font:700 18px 'DM Mono','Nunito Sans',sans-serif;letter-spacing:.035em}
|