From 1b55e33ba35b87816c06204860ed3696b748b8d8 Mon Sep 17 00:00:00 2001 From: Samantha Date: Sun, 10 May 2026 03:22:47 +0900 Subject: [PATCH] cleaner presentation and adding a second experience --- public/global.css | 14 ++-- src/App.svelte | 114 +++++++++++++++++++++++++++--- src/components/GameCanvas.svelte | 34 +++++---- src/game/Enemy.js | 2 +- src/routes/Home.svelte | 117 +++++++++++++++++++++++-------- 5 files changed, 215 insertions(+), 66 deletions(-) diff --git a/public/global.css b/public/global.css index b3ab6bb..6060ca2 100644 --- a/public/global.css +++ b/public/global.css @@ -1,15 +1,9 @@ html, body { - position: relative; - width: 100%; - height: 100%; -} - -body { - color: #333; margin: 0; - padding: 8px; + padding: 0; + width: 100%; + min-height: 100%; + background: #000; box-sizing: border-box; - font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, - Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif; } diff --git a/src/App.svelte b/src/App.svelte index 8a33dd5..748c240 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -1,23 +1,117 @@ - +
+ + - \ No newline at end of file + +
+

the full hue

+ +
+ +
+ + diff --git a/src/components/GameCanvas.svelte b/src/components/GameCanvas.svelte index 0f8d5aa..ba6c4cf 100644 --- a/src/components/GameCanvas.svelte +++ b/src/components/GameCanvas.svelte @@ -134,18 +134,19 @@ fragments.push(new Fragment(p, fragData.x, fragData.y, fragData.color)); } - // create enemies from level data + // create enemies and tar only when the game hasn't been completed — + // after beating all levels the player can explore freely enemies = []; - for (const enemyData of levelData.enemies) { - const e = new Enemy(p, enemyData.x, enemyData.y); - e.patrolDistance = enemyData.patrol; - enemies.push(e); - } - - // create tar puddles from level data tarPuddles = []; - for (const tarData of levelData.tar) { - tarPuddles.push(new TarPuddle(p, tarData.x, tarData.y)); + if (!get(gameCompleted)) { + for (const enemyData of levelData.enemies) { + const e = new Enemy(p, enemyData.x, enemyData.y); + e.patrolDistance = enemyData.patrol; + enemies.push(e); + } + for (const tarData of levelData.tar) { + tarPuddles.push(new TarPuddle(p, tarData.x, tarData.y)); + } } }; @@ -228,12 +229,15 @@ } // ── 8. FELL OFF SCREEN ──────────────────────────────────────── - // if player falls below the canvas, lose a life and respawn if (player.sprite.y > p.height + 100 && gameState === 'playing') { - const dead = player.loseLife(lives); - if (dead) { - gameState = 'gameover'; - setTimeout(() => push(`/gameover?level=${levelNumber}`), 500); + if (get(gameCompleted)) { + player.respawn(); // NG+: no damage, just put them back + } else { + const dead = player.loseLife(lives); + if (dead) { + gameState = 'gameover'; + setTimeout(() => push(`/gameover?level=${levelNumber}`), 500); + } } } diff --git a/src/game/Enemy.js b/src/game/Enemy.js index fea0489..26da57d 100644 --- a/src/game/Enemy.js +++ b/src/game/Enemy.js @@ -9,7 +9,7 @@ export class Enemy{ this.speed = 1.5; this.direction = 1 // 1 is right, -1 is left this.startX = x; - this.patrolDisctance = 100; // how far it can walk + this.patrolDistance = 100; // how far it can walk } update(){ diff --git a/src/routes/Home.svelte b/src/routes/Home.svelte index 66390db..12a38c5 100644 --- a/src/routes/Home.svelte +++ b/src/routes/Home.svelte @@ -1,6 +1,6 @@
- -
-

The Full Hue

-

Bring back your color

- -
+ {#if $gameCompleted} + + +
+

The Full Hue

+

you've brought all the color back.

+

+ go through the world again — now in full color and without sorrows.
+ take your time. view the scenery. learn about your hues. +

+ +
+ + {:else} + + +
+

The Full Hue

+

Bring back your color

+ +
+ + {/if} +
\ No newline at end of file + + button:hover { background: rgba(255, 255, 255, 0.3); } +