From e153cbdb9a0e7d306ebc66bf37c4f0ddb931f0fa Mon Sep 17 00:00:00 2001 From: Ronni Skansing Date: Thu, 20 Nov 2025 00:43:43 +0100 Subject: [PATCH] slop snake Signed-off-by: Ronni Skansing --- .../lib/components/games/GameLauncher.svelte | 118 ++ .../src/lib/components/games/SnakeGame.svelte | 1427 +++++++++++++++++ frontend/src/routes/+layout.svelte | 2 + 3 files changed, 1547 insertions(+) create mode 100644 frontend/src/lib/components/games/GameLauncher.svelte create mode 100644 frontend/src/lib/components/games/SnakeGame.svelte diff --git a/frontend/src/lib/components/games/GameLauncher.svelte b/frontend/src/lib/components/games/GameLauncher.svelte new file mode 100644 index 0000000..e8f91f4 --- /dev/null +++ b/frontend/src/lib/components/games/GameLauncher.svelte @@ -0,0 +1,118 @@ + + +{#if gameVisible} + + +
+ + +
+ +
+
+
+ + + + + +
+

+ {currentGame.emoji} + {currentGame.title} + {currentGame.emoji} +

+

press esc to close

+
+ + +
+ +
+
+
+{/if} + + diff --git a/frontend/src/lib/components/games/SnakeGame.svelte b/frontend/src/lib/components/games/SnakeGame.svelte new file mode 100644 index 0000000..cae1d0a --- /dev/null +++ b/frontend/src/lib/components/games/SnakeGame.svelte @@ -0,0 +1,1427 @@ + + +
+ {#if gameStarted} +
+
+
score
+
{score}
+
+
+
high score
+
{highScores.length > 0 ? highScores[0].score : 0}
+
+
+ {/if} + +
+ + + + {#if !gameStarted} +
+
+
+
collect:
+
+ {#each credTypes as cred} +
+ {cred.emoji} + {cred.type} + +{cred.points} +
+ {/each} +
+
+ +
+
avoid (red outline):
+
+ {#each hazardTypes as hazard} +
+ {hazard.emoji} + {hazard.type} +
+ {/each} +
+
+ +
+
bonuses:
+
+ {#each bonusTypes as bonus} +
+ {bonus.emoji} + {bonus.effect} +
+ {/each} +
+
+
+ + +
+ {:else if showHighScoreEntry} + + +
+
new high score!
+
score: {score}
+
+ + { + if (e.key === 'Enter') submitHighScore(); + e.stopPropagation(); + }} + on:click|stopPropagation + class="px-4 py-2 bg-pc-darkblue border-2 border-pc-pink rounded text-white text-center text-2xl uppercase font-bold focus:outline-none focus:border-pc-pink-hover" + placeholder="AAA" + /> +
+ +
+ {:else if gameOver} +
+
game over!
+
score: {score}
+ + {#if highScores.length > 0} +
+
+ top 3 scores: +
+
+ {#each highScores as hs, i} +
+ {i + 1}. {hs.name} + {hs.score} +
+ {/each} +
+
+ {/if} + + +
+ {/if} +
+ + {#if gameStarted} +
+ {#if activeBonus} +
+
+ {activeBonus.type === '2x' + ? '✨ 2X POINTS' + : activeBonus.type === 'trippy' + ? '🌀 RAINBOW MODE' + : activeBonus.type === 'shield' + ? wallHitGracePeriod + ? '🛡️ SHIELD - GRACE PERIOD!' + : '🛡️ SHIELD ACTIVE' + : activeBonus.type === 'supertrip' + ? '🍄 PSYCHEDELIC MODE' + : activeBonus.type === 'ultra' + ? '💫 ULTRA MODE - INVINCIBLE!' + : activeBonus.type === 'ghost' + ? '👤 GHOST MODE - PASS THROUGH!' + : activeBonus.type === 'magnet' + ? '🧲 MAGNET - ATTRACTING FOOD!' + : '⚡ SLOW MOTION'} +
+
+ {:else if eventWarning} +
+
+ ⚠️ WARNING: {eventWarning.message.toUpperCase()} IN {Math.max( + 1, + Math.ceil((3000 - (Date.now() - eventWarningTimer)) / 1000) + )}s +
+
+ {:else if currentEvent} +
+
{currentEvent.message}
+
+ {:else if wallCycleTime - wallTimer <= wallWarningTime && !wallsActive} +
+
+ ⚠️ WALLS ACTIVATING IN {Math.ceil((wallCycleTime - wallTimer) / 10)}s! +
+
+ {/if} +
+ {/if} +
+ + diff --git a/frontend/src/routes/+layout.svelte b/frontend/src/routes/+layout.svelte index 761d8ec..6ca5e30 100644 --- a/frontend/src/routes/+layout.svelte +++ b/frontend/src/routes/+layout.svelte @@ -19,6 +19,7 @@ import { hideIsLoading, showIsLoading } from '$lib/store/loading'; import Header from '$lib/components/header/Header.svelte'; import { setupTheme, setupOSThemeListener } from '$lib/theme.js'; + import GameLauncher from '$lib/components/games/GameLauncher.svelte'; // Removed feature flags import - no longer needed // services @@ -239,6 +240,7 @@ +