diff --git a/README.md b/README.md index b756bde..aa7350f 100644 --- a/README.md +++ b/README.md @@ -5,4 +5,95 @@ **Email**: samantha@kaist.ac.kr **Gittea Repo**: [https://git.prototyping.id/20266142/The-Full-Hue](https://git.prototyping.id/20266142/The-Full-Hue) - \ No newline at end of file + + **Video Demo**: []() + + # Game Description + _The Full Hue_ is a 2D platformer game based around the themes of color and emotion. The game begins completely gray. Each level is themed around a specific color and its corresponding meaning: orange is warmth and creativity, yellow is joy and anxiety, blue is depth, and so on. The goal is to collect the color fragments scattered across each levels platforms, restoring color to the world one hue at a time. + + ### How to play: +Move utilizing the arrow keys or WASD + +| Key | Action | +|--------|-----| +| `← →` or `A D` | Move left/right | +| `Space`, ` ↑`, or `w`| Jump| + +**Collecting Fragments:** small glowing fragments are placed on the platforms aross each level, to collect them simply walk into them. As they are picked up a small quote appears at the top of the screen and the level's background is gradually tinted to its corresponding color. + +**Avoid Hazards:** Enemies walk back and forth on platform. Tar puddles sit on the ground floor. Coming into contact with either costs the player a life, there are 3 lives per level. Taking damage triggers a short invincibility period with a blinking effect so that the player can recover and reset. + +**Compleating the level:** You successfully complete a level by collecting every fragment at that stage. An overaly with a short reflection will be shown upon level compleation which will allow you to move to the next level. + +**Game progess:** Levels unlock sequentially as they are completed. Compleating a level permanently unlock the next one, making it visible on the level select screen. Locked levels show a `?` symbol. + +### After beating all levels + +Once all 10 levels are compleated the game enters a free explore mode. The home screen changes to a new message inviting the player to go through the game again now in full color and without obstacles. Re-entering the game levels removes the tar puddles and enemies and the backgrounds are shown in full color. The game becomes a sort of gallery inviting the player to walk through each level again appreciating the art and reading the messages at a more leisurely pace. + +# Code organization + +### The file structure + +My files are organized as illustrated below: + +![file organization](/svelteP5Play/public/documentation/File%20organization.png) + +### Game Screen + +using `Game.svelte` I layer four compnents in a single `800x450` container. The organization is as follows: + +| component | contents | z-index| +|-----------|----------|--------| +| GameCanvas | p5 canvas | 0 | +| HUD overlay | lives and fragment info display | 10 | +| QuoteToast | quote displayed on fragment collection | 20 | +| LevelCompleteOverlay | Final level quote & next level button | 30 | + +### How GameCanvas.svelte runs the game loop + +The p5 `draw()` function is going at 60fps and doing the following each frame: + + - Draw the background image + - `allSprites.update()` - checks for collisions & handles p5play physics + - updates the color tint overlay + - `fragment.drawGlow() and update()` - fragment animation and callback in case of collection + - `enemy.update()` and overlap check - enemy animation and updates lives in case of overlap + - tar overlap check - updates lives on overlap + - splat effect called when triggered + - fall-off-screen check for avatar + - `allSprites.draw()` - render all the sprites using p5play + +### LevelData.js Organization + +``` +{ + id, + name, + color, + bg, + bgcomplete, + playerImg, + spawnX, + spawnY, + platforms: [{x,y,w,h},...], + fragments: [{x,y,color},...], + enemies: [{x,y,patrol},...], + tar: [{x,y},...], + fragmentQuotes: [{'...','...'}], + completeQuote: '...', +} +``` + +`gameCanvas.setup()` reads this information and draws the game objects from it. This makes it easier to create new levels, change platform positions, text, etc. by only having to update the information on this file. + +### Svelte stores (An observer pattern?) - shared states + +stores essentially hold all the global variables and states. If the values are changed all files are able to see this and automatically re-render. We are able to do this with Svelte's `$store` sytanx. + +colorStore.js + +| Function | purpose | +|----------|---------| +| `lives` | player lives (0-3)| +| `colorOpacity` | \ No newline at end of file diff --git a/public/documentation/File organization.png b/public/documentation/File organization.png new file mode 100644 index 0000000..39796bf Binary files /dev/null and b/public/documentation/File organization.png differ diff --git a/src/components/GameCanvas.svelte b/src/components/GameCanvas.svelte index ba6c4cf..34e9502 100644 --- a/src/components/GameCanvas.svelte +++ b/src/components/GameCanvas.svelte @@ -19,7 +19,7 @@ const keysDown = { left: false, right: false, jump: false }; const onKeyDown = (e) => { - if (e.key === 'Escape') { push('/levelselect'); return; } + if (e.key === 'Escape' || e.key === 'e' || e.key === 'E') { push('/levelselect'); return; } if (e.key === 'ArrowLeft' || e.key === 'a') { keysDown.left = true; e.preventDefault(); } if (e.key === 'ArrowRight' || e.key === 'd') { keysDown.right = true; e.preventDefault(); } // e.repeat blocks the browser auto-repeat from re-queuing a jump while held diff --git a/src/routes/Home.svelte b/src/routes/Home.svelte index 12a38c5..55af370 100644 --- a/src/routes/Home.svelte +++ b/src/routes/Home.svelte @@ -1,30 +1,249 @@
{#if $gameCompleted} + + +

The Full Hue

you've brought all the color back.

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

+ {:else if showControls} + + +
+

how to play

+

a short guide before your journey begins

+ +
+
+
+ + + or + A + D +
+ · + move left / right +
+
+
+ + or + W + or + SPACE +
+ · + jump +
+
+
+ E +
+ · + open level select +
+
+ +

try it out ↓

+
+ + +
+ {:else} - +

The Full Hue

Bring back your color

@@ -126,4 +345,126 @@ } button:hover { background: rgba(255, 255, 255, 0.3); } + + /* ── NG+ sparkle layer ── */ + .sparkfield { + position: absolute; + inset: 0; + pointer-events: none; + } + + .spark { + position: absolute; + border-radius: 50%; + animation: sparkle linear infinite; + } + + @keyframes sparkle { + 0%, 100% { opacity: 1; transform: scale(1); } + 50% { opacity: 0.05; transform: scale(0.4); } + } + + /* ── controls screen ── */ + .controls-content { + gap: 9px; + padding: 0 60px; + } + + h2 { + font-family: 'Courier New', Courier, monospace; + font-size: 28px; + font-weight: 400; + margin: 0; + } + + .ctrl-sub { + font-family: 'Courier New', Courier, monospace; + font-size: 13px; + color: rgba(255, 255, 255, 0.38); + margin: 0; + } + + .key-table { + display: flex; + flex-direction: column; + gap: 7px; + margin: 4px 0 2px; + } + + .key-row { + display: flex; + align-items: center; + gap: 14px; + } + + .keys { + display: flex; + align-items: center; + gap: 4px; + min-width: 218px; + } + + .key { + display: inline-flex; + align-items: center; + justify-content: center; + min-width: 28px; + height: 24px; + padding: 0 7px; + background: rgba(255, 255, 255, 0.09); + border: 1px solid rgba(255, 255, 255, 0.28); + border-bottom: 2px solid rgba(255, 255, 255, 0.28); + border-radius: 5px; + font-family: 'Courier New', Courier, monospace; + font-size: 11px; + color: rgba(255, 255, 255, 0.82); + box-sizing: border-box; + } + + .key.wide { + min-width: 62px; + letter-spacing: 0.04em; + } + + .or { + font-family: 'Courier New', Courier, monospace; + font-size: 10px; + color: rgba(255, 255, 255, 0.22); + padding: 0 1px; + } + + .dot { + color: rgba(255, 255, 255, 0.18); + font-size: 16px; + line-height: 1; + } + + .key-desc { + font-family: 'Courier New', Courier, monospace; + font-size: 13px; + color: rgba(255, 255, 255, 0.58); + } + + .try-label { + font-family: 'Courier New', Courier, monospace; + font-size: 11px; + color: rgba(255, 255, 255, 0.22); + margin: 0; + text-align: center; + } + + .mini-canvas-wrap { + width: 680px; + height: 124px; + border-radius: 8px; + overflow: hidden; + border: 1px solid rgba(255, 255, 255, 0.07); + } + + /* controls-content button gets less top margin */ + .controls-content button { + margin-top: 6px; + font-size: 18px; + padding: 10px 36px; + } diff --git a/src/routes/Win.svelte b/src/routes/Win.svelte index f31636a..f4e3081 100644 --- a/src/routes/Win.svelte +++ b/src/routes/Win.svelte @@ -1,12 +1,52 @@
+ +

color restored

-

every fragment found. every hue returned

-

Go forth and experience the world in full color.

- +

every fragment found. every hue returned

+

Go forth and experience the world in all its colors.

diff --git a/src/routes/Win.svelte.bak b/src/routes/Win.svelte.bak new file mode 100644 index 0000000..f31636a --- /dev/null +++ b/src/routes/Win.svelte.bak @@ -0,0 +1,77 @@ + + +
+

color restored

+

every fragment found. every hue returned

+

Go forth and experience the world in full color.

+ +
+ + diff --git a/src/stores/colorStore.js b/src/stores/colorStore.js index 51ee61f..7b09834 100644 --- a/src/stores/colorStore.js +++ b/src/stores/colorStore.js @@ -18,6 +18,9 @@ import { LEVELS } from '../game/levelData.js'; // world starts gray so unlockedColors start as an empty array (there is none) export const unlockedColors = writable([]); +// true once the player has seen the controls screen (skip it on future visits) +export const hasSeenControls = writable(false); + // the current level number export const currentLevel = writable(1);