@loonylabs/create-game 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/create-game.js +213 -0
- package/package.json +18 -0
- package/template/.claude/skills/aigdtk-create-game-stories/SKILL.md +177 -0
- package/template/.claude/skills/aigdtk-create-game-stories/story-template.md +85 -0
- package/template/.claude/skills/aigdtk-implement-game-stories/SKILL.md +129 -0
- package/template/.claude/skills/aigdtk-new-game/SKILL.md +126 -0
- package/template/.claude/skills/aigdtk-shared/ascii-grammar.md +133 -0
- package/template/.claude/skills/aigdtk-shared/enemies.md +112 -0
- package/template/.claude/skills/aigdtk-shared/framework.md +93 -0
- package/template/.claude/skills/aigdtk-shared/visuals.md +125 -0
- package/template/apps/client/index.html +14 -0
- package/template/apps/client/package.json +31 -0
- package/template/apps/client/public/assets/audio/enemy_killed.wav +0 -0
- package/template/apps/client/src/components/App.svelte +290 -0
- package/template/apps/client/src/components/CraftingPanel.svelte +253 -0
- package/template/apps/client/src/components/DevPanel.svelte +180 -0
- package/template/apps/client/src/components/DungeonClearOverlay.svelte +53 -0
- package/template/apps/client/src/components/EquipmentPanel.svelte +191 -0
- package/template/apps/client/src/components/HealthBar.svelte +50 -0
- package/template/apps/client/src/components/Hub/BackToHubButton.svelte +37 -0
- package/template/apps/client/src/components/Hub/ExperienceCard.svelte +115 -0
- package/template/apps/client/src/components/Hub/Hub.svelte +88 -0
- package/template/apps/client/src/components/Inventory.svelte +174 -0
- package/template/apps/client/src/components/Runner/RunnerDeathScreen.svelte +182 -0
- package/template/apps/client/src/components/Runner/RunnerHUD.svelte +157 -0
- package/template/apps/client/src/components/Shooter/DamageNumbers.svelte +96 -0
- package/template/apps/client/src/components/Shooter/GameOverScreen.svelte +109 -0
- package/template/apps/client/src/components/Shooter/ShooterHUD.svelte +95 -0
- package/template/apps/client/src/components/SkillBar.svelte +146 -0
- package/template/apps/client/src/components/ToastSystem.svelte +158 -0
- package/template/apps/client/src/game.ts +918 -0
- package/template/apps/client/src/input.ts +92 -0
- package/template/apps/client/src/lib/audio/CombatDetector.test.ts +59 -0
- package/template/apps/client/src/lib/audio/CombatDetector.ts +53 -0
- package/template/apps/client/src/lib/audio/MusicManager.ts +137 -0
- package/template/apps/client/src/lib/audio/SoundManager.ts +59 -0
- package/template/apps/client/src/lib/audio/index.ts +9 -0
- package/template/apps/client/src/main.ts +32 -0
- package/template/apps/client/src/renderer/basecamp.ts +126 -0
- package/template/apps/client/src/renderer/dungeon.ts +250 -0
- package/template/apps/client/src/renderer/dungeonPortal.ts +73 -0
- package/template/apps/client/src/renderer/dungeonZone.ts +301 -0
- package/template/apps/client/src/renderer/entities.ts +197 -0
- package/template/apps/client/src/renderer/runnerTrack.ts +221 -0
- package/template/apps/client/src/renderer/shaders/SkyShader.ts +190 -0
- package/template/apps/client/src/renderer/shaders/TerrainShaderMaterial.ts +133 -0
- package/template/apps/client/src/renderer/shaders/floor.frag.glsl.ts +17 -0
- package/template/apps/client/src/renderer/shaders/shaderConfig.ts +18 -0
- package/template/apps/client/src/renderer/shaders/spawn.frag.glsl.ts +19 -0
- package/template/apps/client/src/renderer/shaders/terrain.frag.glsl.ts +314 -0
- package/template/apps/client/src/renderer/shaders/terrain.vert.glsl.ts +16 -0
- package/template/apps/client/src/renderer/shaders/wall.frag.glsl.ts +20 -0
- package/template/apps/client/src/renderer/shooterArena.ts +102 -0
- package/template/apps/client/src/renderer/voxelChunkStreamer.ts +79 -0
- package/template/apps/client/src/renderer/voxelMesh.ts +86 -0
- package/template/apps/client/src/renderer/voxelTerrain.ts +74 -0
- package/template/apps/client/src/socket.ts +268 -0
- package/template/apps/client/src/store.ts +74 -0
- package/template/apps/client/src/style.css +60 -0
- package/template/apps/client/tsconfig.json +11 -0
- package/template/apps/client/vite.config.ts +10 -0
- package/template/apps/client/vitest.config.ts +8 -0
- package/template/apps/experiences/diablo/index.ts +94 -0
- package/template/apps/experiences/diablo/systems/dungeonClearSystem.ts +60 -0
- package/template/apps/experiences/diablo/systems/enemyAISystem.ts +11 -0
- package/template/apps/experiences/diablo/systems/entitySyncSystem.ts +80 -0
- package/template/apps/experiences/diablo/systems/itemPickupSystem.ts +11 -0
- package/template/apps/experiences/diablo/systems/movementSystem.ts +13 -0
- package/template/apps/experiences/diablo/systems/physicsSystem.ts +92 -0
- package/template/apps/experiences/diablo/systems/transitionSystem.ts +105 -0
- package/template/apps/experiences/runner/data/runner-config.ts +54 -0
- package/template/apps/experiences/runner/index.ts +143 -0
- package/template/apps/experiences/runner/systems/collectibleSystem.ts +157 -0
- package/template/apps/experiences/runner/systems/deathSystem.ts +42 -0
- package/template/apps/experiences/runner/systems/entitySyncSystem.ts +59 -0
- package/template/apps/experiences/runner/systems/obstacleSystem.ts +91 -0
- package/template/apps/experiences/runner/systems/runnerPhysicsSystem.ts +82 -0
- package/template/apps/experiences/runner/systems/trackStreamSystem.ts +19 -0
- package/template/apps/experiences/runner/track/laneSystem.ts +53 -0
- package/template/apps/experiences/runner/track/segmentTypes.ts +141 -0
- package/template/apps/experiences/runner/track/trackGenerator.ts +292 -0
- package/template/apps/experiences/shooter/ai/aiStateMachine.ts +394 -0
- package/template/apps/experiences/shooter/ai/lineOfSight.ts +32 -0
- package/template/apps/experiences/shooter/arena/arenaGenerator.ts +101 -0
- package/template/apps/experiences/shooter/arena/arenaTypes.ts +49 -0
- package/template/apps/experiences/shooter/arena/hitscan.ts +101 -0
- package/template/apps/experiences/shooter/data/enemy-types.ts +108 -0
- package/template/apps/experiences/shooter/data/wave-definitions.ts +40 -0
- package/template/apps/experiences/shooter/data/weapon-config.ts +80 -0
- package/template/apps/experiences/shooter/index.ts +127 -0
- package/template/apps/experiences/shooter/systems/enemyAISystem.ts +113 -0
- package/template/apps/experiences/shooter/systems/entitySyncSystem.ts +68 -0
- package/template/apps/experiences/shooter/systems/shooterPhysicsSystem.ts +89 -0
- package/template/apps/experiences/shooter/systems/waveSpawnerSystem.ts +87 -0
- package/template/apps/experiences/shooter/systems/weaponSystem.ts +157 -0
- package/template/apps/game-data/src/areas/area-manifest.json +18 -0
- package/template/apps/game-data/src/assets/migration.test.ts +291 -0
- package/template/apps/game-data/src/audio/music-config.json +21 -0
- package/template/apps/game-data/src/audio/sound-config.json +11 -0
- package/template/apps/game-data/src/combat/action-types.ts +2 -0
- package/template/apps/game-data/src/combat/enemy-def.ts +12 -0
- package/template/apps/game-data/src/combat/hitboxes.ts +23 -0
- package/template/apps/game-data/src/dungeon/cell-types.ts +20 -0
- package/template/apps/game-data/src/dungeon/cell-visuals.ts +13 -0
- package/template/apps/game-data/src/dungeon/door-directions.ts +2 -0
- package/template/apps/game-data/src/enemies/enemy-defs.json +32 -0
- package/template/apps/game-data/src/equipment/slots.json +5 -0
- package/template/apps/game-data/src/events/event-defs.ts +20 -0
- package/template/apps/game-data/src/events/event-types.ts +10 -0
- package/template/apps/game-data/src/events/toast-config.json +49 -0
- package/template/apps/game-data/src/items/item-pool.json +13 -0
- package/template/apps/game-data/src/loot/item-pool.ts +14 -0
- package/template/apps/game-data/src/loot/rarities.ts +2 -0
- package/template/apps/game-data/src/physics/dungeon-physics-config.ts +12 -0
- package/template/apps/game-data/src/physics/jump-config.ts +17 -0
- package/template/apps/game-data/src/recipes/recipe-book.json +68 -0
- package/template/apps/game-data/src/rooms/room_basecamp.json +16 -0
- package/template/apps/game-data/src/rooms/room_corridor_ew.json +9 -0
- package/template/apps/game-data/src/rooms/room_corridor_ns.json +11 -0
- package/template/apps/game-data/src/rooms/room_crossroads.json +11 -0
- package/template/apps/game-data/src/rooms/room_dead_end.json +10 -0
- package/template/apps/game-data/src/rooms/room_staircase.json +12 -0
- package/template/apps/game-data/src/rooms/room_start.json +11 -0
- package/template/apps/game-data/src/skills/skill-book.json +20 -0
- package/template/apps/game-data/src/voxel/biome-terrain.ts +76 -0
- package/template/apps/game-data/src/voxel/materials.ts +45 -0
- package/template/apps/game-data/src/voxel/sandbox-terrain-config.ts +19 -0
- package/template/apps/game-data/src/world/area-config.ts +33 -0
- package/template/apps/game-data/src/world/biome-def.ts +15 -0
- package/template/apps/game-data/src/world/biomes.json +57 -0
- package/template/apps/game-data/src/world/movement.ts +2 -0
- package/template/apps/game-data/src/world/overworld-layout.test.ts +93 -0
- package/template/apps/game-data/src/world/overworld-layout.ts +127 -0
- package/template/apps/server/data/game.db +0 -0
- package/template/apps/server/package.json +30 -0
- package/template/apps/server/src/areaManager.ts +346 -0
- package/template/apps/server/src/db/client.ts +45 -0
- package/template/apps/server/src/db/schema.ts +40 -0
- package/template/apps/server/src/gameLoop.ts +267 -0
- package/template/apps/server/src/gameState.ts +3 -0
- package/template/apps/server/src/handlers/actionEvent.ts +55 -0
- package/template/apps/server/src/handlers/craftHandler.ts +59 -0
- package/template/apps/server/src/handlers/equipHandler.ts +73 -0
- package/template/apps/server/src/handlers/raycastHandler.ts +97 -0
- package/template/apps/server/src/handlers/skillHandler.ts +87 -0
- package/template/apps/server/src/handlers/terraformHandler.ts +74 -0
- package/template/apps/server/src/index.ts +597 -0
- package/template/apps/server/src/persistence.ts +135 -0
- package/template/apps/server/src/rooms.ts +20 -0
- package/template/apps/server/src/systems/dungeonPhysics.test.ts +32 -0
- package/template/apps/server/src/systems/dungeonPhysics.ts +16 -0
- package/template/apps/server/src/systems/enemyAI.ts +129 -0
- package/template/apps/server/src/systems/itemPickup.ts +31 -0
- package/template/apps/server/src/tests/areaManager.test.ts +77 -0
- package/template/apps/server/src/tests/diablo-experience.test.ts +60 -0
- package/template/apps/server/src/tests/runner-experience.test.ts +273 -0
- package/template/apps/server/src/tests/runner-powerups-scoring.test.ts +221 -0
- package/template/apps/server/src/tests/server.integration.test.ts +92 -0
- package/template/apps/server/src/tests/shooter-enemy-ai.test.ts +328 -0
- package/template/apps/server/src/tests/shooter-experience.test.ts +281 -0
- package/template/apps/server/src/tests/voxelChunkCache.test.ts +29 -0
- package/template/apps/server/src/tests/voxelSandbox.test.ts +133 -0
- package/template/apps/server/src/voxelChunkCache.ts +31 -0
- package/template/apps/server/src/voxelPlayerState.ts +23 -0
- package/template/apps/server/tsconfig.json +17 -0
- package/template/apps/server/vitest.config.ts +8 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { valtioToSvelte, dragState, craftedSlots } from '@loonylabs/gamedev-client';
|
|
3
|
+
import { store } from '../store.js';
|
|
4
|
+
import { sendMessage } from '../socket.js';
|
|
5
|
+
import type { InventoryItem } from '@loonylabs/gamedev-protocol';
|
|
6
|
+
|
|
7
|
+
export let visible = false;
|
|
8
|
+
|
|
9
|
+
const inventoryStore = valtioToSvelte(store, s => s.inventory);
|
|
10
|
+
const equipInteraction = valtioToSvelte(store, s => s.equipInteraction);
|
|
11
|
+
// Local copy for instant re-renders on drag — synced from store on every server update
|
|
12
|
+
let displayInventory: InventoryItem[] = [];
|
|
13
|
+
$: displayInventory = $inventoryStore;
|
|
14
|
+
|
|
15
|
+
const COLS = 10;
|
|
16
|
+
const ROWS = 4;
|
|
17
|
+
|
|
18
|
+
let dragOverIdx: number | null = null;
|
|
19
|
+
|
|
20
|
+
function rarityColor(rarity: string): string {
|
|
21
|
+
switch (rarity) {
|
|
22
|
+
case 'rare': return 'var(--color-rarity-rare)';
|
|
23
|
+
case 'unique': return 'var(--color-rarity-unique)';
|
|
24
|
+
default: return 'var(--color-rarity-common)';
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function onDragStart(idx: number) {
|
|
29
|
+
dragState.set({ source: 'inventory', index: idx });
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function onDragOver(idx: number) {
|
|
33
|
+
dragOverIdx = idx;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function onDragLeave() {
|
|
37
|
+
dragOverIdx = null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function onDrop(targetIdx: number) {
|
|
41
|
+
dragOverIdx = null;
|
|
42
|
+
const ds = $dragState;
|
|
43
|
+
if (!ds) return;
|
|
44
|
+
|
|
45
|
+
if (ds.source === 'inventory') {
|
|
46
|
+
const items = displayInventory.map(i => ({ ...i }));
|
|
47
|
+
const srcItem = items.find(i => i.slot === ds.index);
|
|
48
|
+
const dstItem = items.find(i => i.slot === targetIdx);
|
|
49
|
+
if (srcItem) srcItem.slot = targetIdx;
|
|
50
|
+
if (dstItem) dstItem.slot = ds.index;
|
|
51
|
+
displayInventory = items; // instant Svelte re-render
|
|
52
|
+
store.inventory = items; // sync Valtio for server messages / other components
|
|
53
|
+
} else if (ds.source === 'equipment' && ds.slotId) {
|
|
54
|
+
// Drag from equipment slot back to inventory → unequip
|
|
55
|
+
sendMessage({ type: 'UNEQUIP_REQUEST', slotId: ds.slotId });
|
|
56
|
+
}
|
|
57
|
+
dragState.set(null);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function onDragEnd() {
|
|
61
|
+
dragOverIdx = null;
|
|
62
|
+
dragState.set(null);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function guessSlot(statBonus: Record<string, number> | undefined): string | null {
|
|
66
|
+
if (!statBonus) return null;
|
|
67
|
+
const keys = Object.keys(statBonus);
|
|
68
|
+
if (keys.includes('attack') && keys.includes('defense')) return 'ring';
|
|
69
|
+
if (keys.includes('attack')) return 'weapon';
|
|
70
|
+
if (keys.includes('defense')) return 'armor';
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function onDoubleClick(item: InventoryItem) {
|
|
75
|
+
if ($equipInteraction === 'drag') return;
|
|
76
|
+
const slotId = guessSlot(item.statBonus);
|
|
77
|
+
if (!slotId) return; // item has no equippable stats (e.g. speed-only, hp-only)
|
|
78
|
+
sendMessage({ type: 'EQUIP_REQUEST', slotId, itemId: item.id });
|
|
79
|
+
}
|
|
80
|
+
</script>
|
|
81
|
+
|
|
82
|
+
{#if visible}
|
|
83
|
+
<div class="inventory-panel" role="dialog" aria-label="Inventory">
|
|
84
|
+
<div class="inventory-title">Inventory</div>
|
|
85
|
+
<div class="inventory-grid" style="grid-template-columns: repeat({COLS}, 1fr);">
|
|
86
|
+
{#each Array(ROWS * COLS) as _, idx}
|
|
87
|
+
{@const item = displayInventory.find(i => i.slot === idx)}
|
|
88
|
+
<div
|
|
89
|
+
class="slot"
|
|
90
|
+
class:filled={!!item}
|
|
91
|
+
class:drag-over={dragOverIdx === idx}
|
|
92
|
+
draggable={!!item && !$craftedSlots.has(idx)}
|
|
93
|
+
style={item ? `background: ${rarityColor(item.rarity)}22; border-color: ${rarityColor(item.rarity)};` : ''}
|
|
94
|
+
title={item ? item.name : ''}
|
|
95
|
+
on:dragstart={() => item && !$craftedSlots.has(idx) && onDragStart(idx)}
|
|
96
|
+
on:dragover|preventDefault={() => onDragOver(idx)}
|
|
97
|
+
on:dragleave={onDragLeave}
|
|
98
|
+
on:drop={() => onDrop(idx)}
|
|
99
|
+
on:dragend={onDragEnd}
|
|
100
|
+
on:dblclick={() => item && onDoubleClick(item)}
|
|
101
|
+
role="listitem"
|
|
102
|
+
>
|
|
103
|
+
{#if item}
|
|
104
|
+
<span
|
|
105
|
+
class="item-name"
|
|
106
|
+
style="color: {rarityColor(item.rarity)}; opacity: {($dragState?.source === 'inventory' && $dragState?.index === idx) || $craftedSlots.has(idx) ? 0.4 : 1};"
|
|
107
|
+
>
|
|
108
|
+
{item.name.split(' ')[0]}
|
|
109
|
+
</span>
|
|
110
|
+
{/if}
|
|
111
|
+
</div>
|
|
112
|
+
{/each}
|
|
113
|
+
</div>
|
|
114
|
+
</div>
|
|
115
|
+
{/if}
|
|
116
|
+
|
|
117
|
+
<style>
|
|
118
|
+
.inventory-panel {
|
|
119
|
+
position: absolute;
|
|
120
|
+
top: 50%;
|
|
121
|
+
left: 50%;
|
|
122
|
+
transform: translate(-50%, -50%);
|
|
123
|
+
background: rgba(10, 10, 10, 0.95);
|
|
124
|
+
border: 1px solid #444;
|
|
125
|
+
padding: 16px;
|
|
126
|
+
pointer-events: auto;
|
|
127
|
+
user-select: none;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.inventory-title {
|
|
131
|
+
color: #aaa;
|
|
132
|
+
font-size: 0.75rem;
|
|
133
|
+
letter-spacing: 0.1em;
|
|
134
|
+
text-transform: uppercase;
|
|
135
|
+
margin-bottom: 10px;
|
|
136
|
+
text-align: center;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.inventory-grid {
|
|
140
|
+
display: grid;
|
|
141
|
+
gap: 3px;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.slot {
|
|
145
|
+
width: 48px;
|
|
146
|
+
height: 48px;
|
|
147
|
+
background: var(--color-slot-empty);
|
|
148
|
+
border: 1px solid var(--color-slot-border);
|
|
149
|
+
display: flex;
|
|
150
|
+
align-items: center;
|
|
151
|
+
justify-content: center;
|
|
152
|
+
font-size: 0.55rem;
|
|
153
|
+
text-align: center;
|
|
154
|
+
overflow: hidden;
|
|
155
|
+
position: relative;
|
|
156
|
+
cursor: default;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.slot[draggable="true"] {
|
|
160
|
+
cursor: grab;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.slot.drag-over {
|
|
164
|
+
border-color: #88aaff;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.item-name {
|
|
168
|
+
font-size: 0.5rem;
|
|
169
|
+
line-height: 1.1;
|
|
170
|
+
text-align: center;
|
|
171
|
+
padding: 2px;
|
|
172
|
+
word-break: break-word;
|
|
173
|
+
}
|
|
174
|
+
</style>
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onMount, onDestroy } from 'svelte';
|
|
3
|
+
import { valtioToSvelte } from '@loonylabs/gamedev-client';
|
|
4
|
+
import { store } from '../../store.js';
|
|
5
|
+
import { sendMessage } from '../../socket.js';
|
|
6
|
+
|
|
7
|
+
const distance = valtioToSvelte(store, s => s.runnerDistance);
|
|
8
|
+
const score = valtioToSvelte(store, s => s.runnerScore);
|
|
9
|
+
const coins = valtioToSvelte(store, s => s.runnerCoins);
|
|
10
|
+
const gems = valtioToSvelte(store, s => s.runnerGems);
|
|
11
|
+
const bestCombo = valtioToSvelte(store, s => s.runnerBestCombo);
|
|
12
|
+
const highScore = valtioToSvelte(store, s => s.runnerHighScore);
|
|
13
|
+
|
|
14
|
+
$: isNewRecord = $score > 0 && $score >= $highScore;
|
|
15
|
+
|
|
16
|
+
function restart() {
|
|
17
|
+
sendMessage({ type: 'RUNNER_RESTART' });
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function backToHub() {
|
|
21
|
+
sendMessage({ type: 'EXPERIENCE_LEAVE' });
|
|
22
|
+
store.currentExperience = null;
|
|
23
|
+
store.experienceLoading = false;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function onKeyDown(e: KeyboardEvent) {
|
|
27
|
+
if (e.code === 'KeyR') restart();
|
|
28
|
+
if (e.code === 'KeyB') backToHub();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
onMount(() => window.addEventListener('keydown', onKeyDown));
|
|
32
|
+
onDestroy(() => window.removeEventListener('keydown', onKeyDown));
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<div class="death-overlay">
|
|
36
|
+
<div class="death-box">
|
|
37
|
+
<h1>Game Over</h1>
|
|
38
|
+
{#if isNewRecord}
|
|
39
|
+
<div class="new-record">New Record!</div>
|
|
40
|
+
{/if}
|
|
41
|
+
<div class="final-score">{$score}</div>
|
|
42
|
+
<div class="stats">
|
|
43
|
+
<div class="stat-row">
|
|
44
|
+
<span class="label">Distance</span>
|
|
45
|
+
<span class="value">{$distance}m</span>
|
|
46
|
+
</div>
|
|
47
|
+
<div class="stat-row">
|
|
48
|
+
<span class="label">Coins</span>
|
|
49
|
+
<span class="value">{$coins}</span>
|
|
50
|
+
</div>
|
|
51
|
+
{#if $gems > 0}
|
|
52
|
+
<div class="stat-row">
|
|
53
|
+
<span class="label">Gems</span>
|
|
54
|
+
<span class="value">{$gems}</span>
|
|
55
|
+
</div>
|
|
56
|
+
{/if}
|
|
57
|
+
<div class="stat-row">
|
|
58
|
+
<span class="label">Best Combo</span>
|
|
59
|
+
<span class="value">x{$bestCombo}</span>
|
|
60
|
+
</div>
|
|
61
|
+
<div class="stat-row">
|
|
62
|
+
<span class="label">High Score</span>
|
|
63
|
+
<span class="value">{$highScore}</span>
|
|
64
|
+
</div>
|
|
65
|
+
</div>
|
|
66
|
+
<div class="buttons">
|
|
67
|
+
<button class="btn restart" on:click={restart}>Play Again (R)</button>
|
|
68
|
+
<button class="btn hub" on:click={backToHub}>Back to Hub (B)</button>
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
72
|
+
|
|
73
|
+
<style>
|
|
74
|
+
.death-overlay {
|
|
75
|
+
position: absolute;
|
|
76
|
+
inset: 0;
|
|
77
|
+
background: rgba(0, 0, 0, 0.75);
|
|
78
|
+
display: flex;
|
|
79
|
+
align-items: center;
|
|
80
|
+
justify-content: center;
|
|
81
|
+
z-index: 100;
|
|
82
|
+
font-family: 'Courier New', monospace;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.death-box {
|
|
86
|
+
background: rgba(20, 20, 30, 0.95);
|
|
87
|
+
border: 1px solid #335;
|
|
88
|
+
border-radius: 8px;
|
|
89
|
+
padding: 32px 48px;
|
|
90
|
+
text-align: center;
|
|
91
|
+
min-width: 320px;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
h1 {
|
|
95
|
+
color: #cc4444;
|
|
96
|
+
font-size: 2rem;
|
|
97
|
+
margin: 0 0 8px 0;
|
|
98
|
+
letter-spacing: 0.1em;
|
|
99
|
+
text-transform: uppercase;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.new-record {
|
|
103
|
+
color: #ffcc00;
|
|
104
|
+
font-size: 1.1rem;
|
|
105
|
+
font-weight: bold;
|
|
106
|
+
text-shadow: 0 0 10px rgba(255, 204, 0, 0.5);
|
|
107
|
+
margin-bottom: 8px;
|
|
108
|
+
animation: pulse 0.6s ease-in-out infinite alternate;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.final-score {
|
|
112
|
+
font-size: 2.5rem;
|
|
113
|
+
font-weight: bold;
|
|
114
|
+
color: #ffcc00;
|
|
115
|
+
text-shadow: 0 0 12px rgba(255, 204, 0, 0.4);
|
|
116
|
+
margin-bottom: 16px;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.stats {
|
|
120
|
+
margin: 16px 0 24px 0;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.stat-row {
|
|
124
|
+
display: flex;
|
|
125
|
+
justify-content: space-between;
|
|
126
|
+
padding: 6px 0;
|
|
127
|
+
border-bottom: 1px solid #222;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.label {
|
|
131
|
+
color: #888;
|
|
132
|
+
font-size: 0.85rem;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.value {
|
|
136
|
+
color: #44ccff;
|
|
137
|
+
font-size: 0.95rem;
|
|
138
|
+
font-weight: bold;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.buttons {
|
|
142
|
+
display: flex;
|
|
143
|
+
gap: 12px;
|
|
144
|
+
justify-content: center;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.btn {
|
|
148
|
+
padding: 8px 24px;
|
|
149
|
+
border-radius: 4px;
|
|
150
|
+
font-family: 'Courier New', monospace;
|
|
151
|
+
font-size: 0.8rem;
|
|
152
|
+
letter-spacing: 0.05em;
|
|
153
|
+
cursor: pointer;
|
|
154
|
+
text-transform: uppercase;
|
|
155
|
+
border: 1px solid;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.restart {
|
|
159
|
+
background: rgba(68, 204, 255, 0.2);
|
|
160
|
+
border-color: #44ccff;
|
|
161
|
+
color: #44ccff;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.restart:hover {
|
|
165
|
+
background: rgba(68, 204, 255, 0.35);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.hub {
|
|
169
|
+
background: rgba(136, 136, 136, 0.15);
|
|
170
|
+
border-color: #666;
|
|
171
|
+
color: #aaa;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.hub:hover {
|
|
175
|
+
background: rgba(136, 136, 136, 0.3);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
@keyframes pulse {
|
|
179
|
+
from { transform: scale(1); }
|
|
180
|
+
to { transform: scale(1.05); }
|
|
181
|
+
}
|
|
182
|
+
</style>
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { valtioToSvelte } from '@loonylabs/gamedev-client';
|
|
3
|
+
import { store } from '../../store.js';
|
|
4
|
+
|
|
5
|
+
const distance = valtioToSvelte(store, s => s.runnerDistance);
|
|
6
|
+
const speed = valtioToSvelte(store, s => s.runnerSpeed);
|
|
7
|
+
const score = valtioToSvelte(store, s => s.runnerScore);
|
|
8
|
+
const coins = valtioToSvelte(store, s => s.runnerCoins);
|
|
9
|
+
const combo = valtioToSvelte(store, s => s.runnerCombo);
|
|
10
|
+
const collectFlash = valtioToSvelte(store, s => s.runnerCollectFlash);
|
|
11
|
+
const powerupFlash = valtioToSvelte(store, s => s.runnerPowerupFlash);
|
|
12
|
+
const magnetActive = valtioToSvelte(store, s => s.runnerMagnetActive);
|
|
13
|
+
const hasSpeedBoost = valtioToSvelte(store, s => s.runnerHasSpeedBoost);
|
|
14
|
+
const hasLowGravity = valtioToSvelte(store, s => s.runnerHasLowGravity);
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<div class="runner-hud">
|
|
18
|
+
<div class="score">{$score}</div>
|
|
19
|
+
{#if $combo > 1}
|
|
20
|
+
<div class="combo">x{$combo}</div>
|
|
21
|
+
{/if}
|
|
22
|
+
<div class="distance">{$distance}m</div>
|
|
23
|
+
<div class="coins">{$coins} coins</div>
|
|
24
|
+
<div class="speed">{Math.round($speed * 3.6)} km/h</div>
|
|
25
|
+
|
|
26
|
+
{#if $hasSpeedBoost || $hasLowGravity || $magnetActive}
|
|
27
|
+
<div class="powerups">
|
|
28
|
+
{#if $hasSpeedBoost}<span class="powerup speed-boost">SPEED</span>{/if}
|
|
29
|
+
{#if $hasLowGravity}<span class="powerup low-gravity">LOW-G</span>{/if}
|
|
30
|
+
{#if $magnetActive}<span class="powerup magnet">MAGNET</span>{/if}
|
|
31
|
+
</div>
|
|
32
|
+
{/if}
|
|
33
|
+
|
|
34
|
+
{#if $collectFlash}
|
|
35
|
+
<div class="collect-flash">{$collectFlash}</div>
|
|
36
|
+
{/if}
|
|
37
|
+
|
|
38
|
+
{#if $powerupFlash}
|
|
39
|
+
<div class="powerup-flash">{$powerupFlash}</div>
|
|
40
|
+
{/if}
|
|
41
|
+
|
|
42
|
+
<div class="controls">A/D = Dodge · Space = Jump · Hold Space = Glide</div>
|
|
43
|
+
</div>
|
|
44
|
+
|
|
45
|
+
<style>
|
|
46
|
+
.runner-hud {
|
|
47
|
+
position: absolute;
|
|
48
|
+
top: 60px;
|
|
49
|
+
left: 50%;
|
|
50
|
+
transform: translateX(-50%);
|
|
51
|
+
text-align: center;
|
|
52
|
+
pointer-events: none;
|
|
53
|
+
font-family: 'Courier New', monospace;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.score {
|
|
57
|
+
font-size: 2.5rem;
|
|
58
|
+
font-weight: bold;
|
|
59
|
+
color: #ffcc00;
|
|
60
|
+
text-shadow: 0 0 10px rgba(255, 204, 0, 0.5);
|
|
61
|
+
letter-spacing: 0.05em;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.combo {
|
|
65
|
+
font-size: 1.4rem;
|
|
66
|
+
color: #ff6644;
|
|
67
|
+
font-weight: bold;
|
|
68
|
+
text-shadow: 0 0 8px rgba(255, 102, 68, 0.6);
|
|
69
|
+
animation: pulse 0.5s ease-in-out infinite alternate;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.distance {
|
|
73
|
+
font-size: 1rem;
|
|
74
|
+
color: #44ccff;
|
|
75
|
+
text-shadow: 0 0 6px rgba(68, 204, 255, 0.4);
|
|
76
|
+
margin-top: 4px;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.coins {
|
|
80
|
+
font-size: 0.8rem;
|
|
81
|
+
color: #ffdd44;
|
|
82
|
+
margin-top: 2px;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.speed {
|
|
86
|
+
font-size: 0.75rem;
|
|
87
|
+
color: #88aacc;
|
|
88
|
+
margin-top: 2px;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.powerups {
|
|
92
|
+
display: flex;
|
|
93
|
+
gap: 6px;
|
|
94
|
+
justify-content: center;
|
|
95
|
+
margin-top: 8px;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.powerup {
|
|
99
|
+
padding: 2px 8px;
|
|
100
|
+
border-radius: 3px;
|
|
101
|
+
font-size: 0.65rem;
|
|
102
|
+
font-weight: bold;
|
|
103
|
+
letter-spacing: 0.1em;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.speed-boost {
|
|
107
|
+
background: rgba(255, 100, 0, 0.3);
|
|
108
|
+
border: 1px solid #ff6400;
|
|
109
|
+
color: #ff8833;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.low-gravity {
|
|
113
|
+
background: rgba(100, 200, 255, 0.3);
|
|
114
|
+
border: 1px solid #64c8ff;
|
|
115
|
+
color: #88ddff;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.magnet {
|
|
119
|
+
background: rgba(200, 100, 255, 0.3);
|
|
120
|
+
border: 1px solid #c864ff;
|
|
121
|
+
color: #dd88ff;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.collect-flash {
|
|
125
|
+
font-size: 1.1rem;
|
|
126
|
+
color: #ffee44;
|
|
127
|
+
font-weight: bold;
|
|
128
|
+
margin-top: 8px;
|
|
129
|
+
animation: fadeUp 0.6s ease-out forwards;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.powerup-flash {
|
|
133
|
+
font-size: 1.3rem;
|
|
134
|
+
color: #44ffaa;
|
|
135
|
+
font-weight: bold;
|
|
136
|
+
margin-top: 6px;
|
|
137
|
+
text-shadow: 0 0 12px rgba(68, 255, 170, 0.6);
|
|
138
|
+
animation: fadeUp 1.5s ease-out forwards;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.controls {
|
|
142
|
+
font-size: 0.6rem;
|
|
143
|
+
color: #556;
|
|
144
|
+
margin-top: 8px;
|
|
145
|
+
letter-spacing: 0.05em;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
@keyframes pulse {
|
|
149
|
+
from { transform: scale(1); }
|
|
150
|
+
to { transform: scale(1.1); }
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
@keyframes fadeUp {
|
|
154
|
+
from { opacity: 1; transform: translateY(0); }
|
|
155
|
+
to { opacity: 0; transform: translateY(-20px); }
|
|
156
|
+
}
|
|
157
|
+
</style>
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onMount, onDestroy } from 'svelte';
|
|
3
|
+
import { eventBus } from '@loonylabs/gamedev-client';
|
|
4
|
+
|
|
5
|
+
interface DamageNumber {
|
|
6
|
+
id: number;
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
damage: number;
|
|
10
|
+
age: number;
|
|
11
|
+
killed: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
let numbers: DamageNumber[] = [];
|
|
15
|
+
let nextId = 0;
|
|
16
|
+
let unsub: (() => void) | null = null;
|
|
17
|
+
let raf: number | null = null;
|
|
18
|
+
let lastTime = performance.now();
|
|
19
|
+
|
|
20
|
+
function addNumber(damage: number, screenX: number, screenY: number, killed = false) {
|
|
21
|
+
numbers = [...numbers, {
|
|
22
|
+
id: nextId++,
|
|
23
|
+
x: screenX + (Math.random() - 0.5) * 30,
|
|
24
|
+
y: screenY,
|
|
25
|
+
damage,
|
|
26
|
+
age: 0,
|
|
27
|
+
killed,
|
|
28
|
+
}];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function tick() {
|
|
32
|
+
const now = performance.now();
|
|
33
|
+
const dt = (now - lastTime) / 1000;
|
|
34
|
+
lastTime = now;
|
|
35
|
+
|
|
36
|
+
numbers = numbers
|
|
37
|
+
.map(n => ({ ...n, age: n.age + dt, y: n.y - 60 * dt }))
|
|
38
|
+
.filter(n => n.age < 1);
|
|
39
|
+
|
|
40
|
+
raf = requestAnimationFrame(tick);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
onMount(() => {
|
|
44
|
+
const unsub1 = eventBus.on('hit_confirm', (event: any) => {
|
|
45
|
+
const cx = window.innerWidth / 2;
|
|
46
|
+
const cy = window.innerHeight / 2;
|
|
47
|
+
addNumber(event.damage, cx + (Math.random() - 0.5) * 60, cy - 40 + (Math.random() - 0.5) * 30);
|
|
48
|
+
});
|
|
49
|
+
const unsub2 = eventBus.on('enemy_killed', () => {
|
|
50
|
+
const cx = window.innerWidth / 2;
|
|
51
|
+
const cy = window.innerHeight / 2;
|
|
52
|
+
addNumber(0, cx, cy - 60, true);
|
|
53
|
+
});
|
|
54
|
+
unsub = () => { unsub1(); unsub2(); };
|
|
55
|
+
lastTime = performance.now();
|
|
56
|
+
raf = requestAnimationFrame(tick);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
onDestroy(() => {
|
|
60
|
+
unsub?.();
|
|
61
|
+
if (raf !== null) cancelAnimationFrame(raf);
|
|
62
|
+
});
|
|
63
|
+
</script>
|
|
64
|
+
|
|
65
|
+
{#each numbers as n (n.id)}
|
|
66
|
+
<div
|
|
67
|
+
class="damage-number"
|
|
68
|
+
class:killed={n.killed}
|
|
69
|
+
style="left: {n.x}px; top: {n.y}px; opacity: {1 - n.age};"
|
|
70
|
+
>
|
|
71
|
+
{#if n.killed}
|
|
72
|
+
KILL
|
|
73
|
+
{:else}
|
|
74
|
+
{n.damage}
|
|
75
|
+
{/if}
|
|
76
|
+
</div>
|
|
77
|
+
{/each}
|
|
78
|
+
|
|
79
|
+
<style>
|
|
80
|
+
.damage-number {
|
|
81
|
+
position: absolute;
|
|
82
|
+
pointer-events: none;
|
|
83
|
+
font-family: 'Courier New', monospace;
|
|
84
|
+
font-size: 1.2rem;
|
|
85
|
+
font-weight: bold;
|
|
86
|
+
color: #ffcc00;
|
|
87
|
+
text-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
|
|
88
|
+
transform: translateX(-50%);
|
|
89
|
+
z-index: 50;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.damage-number.killed {
|
|
93
|
+
color: #ff4444;
|
|
94
|
+
font-size: 1.4rem;
|
|
95
|
+
}
|
|
96
|
+
</style>
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onMount, onDestroy } from 'svelte';
|
|
3
|
+
import { valtioToSvelte } from '@loonylabs/gamedev-client';
|
|
4
|
+
import { store } from '../../store.js';
|
|
5
|
+
import { sendMessage } from '../../socket.js';
|
|
6
|
+
|
|
7
|
+
const waveReached = valtioToSvelte(store, s => s.shooterWaveReached);
|
|
8
|
+
|
|
9
|
+
function restart() {
|
|
10
|
+
sendMessage({ type: 'SHOOTER_RESTART' });
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function backToHub() {
|
|
14
|
+
sendMessage({ type: 'EXPERIENCE_LEAVE' });
|
|
15
|
+
store.currentExperience = null;
|
|
16
|
+
store.experienceLoading = false;
|
|
17
|
+
store.shooterDead = false;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function onKeyDown(e: KeyboardEvent) {
|
|
21
|
+
if (e.code === 'KeyR') restart();
|
|
22
|
+
if (e.code === 'KeyB') backToHub();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
onMount(() => window.addEventListener('keydown', onKeyDown));
|
|
26
|
+
onDestroy(() => window.removeEventListener('keydown', onKeyDown));
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<div class="game-over-overlay">
|
|
30
|
+
<div class="game-over-box">
|
|
31
|
+
<h1 class="game-over-title">Game Over</h1>
|
|
32
|
+
<p class="wave-info">Wave {$waveReached} reached</p>
|
|
33
|
+
<div class="button-row">
|
|
34
|
+
<button class="go-btn restart" on:click={restart}>[R] Restart</button>
|
|
35
|
+
<button class="go-btn hub" on:click={backToHub}>[B] Back to Hub</button>
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
|
|
40
|
+
<style>
|
|
41
|
+
.game-over-overlay {
|
|
42
|
+
position: absolute;
|
|
43
|
+
inset: 0;
|
|
44
|
+
background: rgba(0, 0, 0, 0.75);
|
|
45
|
+
display: flex;
|
|
46
|
+
align-items: center;
|
|
47
|
+
justify-content: center;
|
|
48
|
+
z-index: 200;
|
|
49
|
+
pointer-events: auto;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.game-over-box {
|
|
53
|
+
text-align: center;
|
|
54
|
+
padding: 40px 60px;
|
|
55
|
+
background: rgba(20, 0, 0, 0.9);
|
|
56
|
+
border: 1px solid #cc4444;
|
|
57
|
+
border-radius: 6px;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.game-over-title {
|
|
61
|
+
font-family: 'Courier New', monospace;
|
|
62
|
+
font-size: 2.5rem;
|
|
63
|
+
color: #cc4444;
|
|
64
|
+
margin: 0 0 12px;
|
|
65
|
+
text-transform: uppercase;
|
|
66
|
+
letter-spacing: 0.1em;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.wave-info {
|
|
70
|
+
font-family: 'Courier New', monospace;
|
|
71
|
+
font-size: 1.2rem;
|
|
72
|
+
color: #888;
|
|
73
|
+
margin: 0 0 30px;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.button-row {
|
|
77
|
+
display: flex;
|
|
78
|
+
gap: 16px;
|
|
79
|
+
justify-content: center;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.go-btn {
|
|
83
|
+
padding: 10px 24px;
|
|
84
|
+
font-family: 'Courier New', monospace;
|
|
85
|
+
font-size: 0.9rem;
|
|
86
|
+
text-transform: uppercase;
|
|
87
|
+
letter-spacing: 0.06em;
|
|
88
|
+
border: 1px solid #555;
|
|
89
|
+
border-radius: 3px;
|
|
90
|
+
cursor: pointer;
|
|
91
|
+
background: rgba(0, 0, 0, 0.6);
|
|
92
|
+
color: #aaa;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.go-btn:hover {
|
|
96
|
+
border-color: #888;
|
|
97
|
+
color: #fff;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.go-btn.restart {
|
|
101
|
+
border-color: #44cc44;
|
|
102
|
+
color: #44cc44;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.go-btn.restart:hover {
|
|
106
|
+
background: rgba(68, 204, 68, 0.15);
|
|
107
|
+
color: #88ff88;
|
|
108
|
+
}
|
|
109
|
+
</style>
|