@pinkaphant/create-kolmo 0.1.4 → 0.3.1

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.
Files changed (40) hide show
  1. package/README.md +15 -5
  2. package/bin/create-kolmo.mjs +45 -19
  3. package/package.json +2 -1
  4. package/templates/longline/README.md +14 -0
  5. package/templates/longline/index.html +15 -0
  6. package/templates/longline/package.json +38 -0
  7. package/templates/longline/src/App.tsx +48 -0
  8. package/templates/longline/src/components/Boat.tsx +97 -0
  9. package/templates/longline/src/components/CameraRig.tsx +61 -0
  10. package/templates/longline/src/components/Crates.tsx +48 -0
  11. package/templates/longline/src/components/Hud.tsx +197 -0
  12. package/templates/longline/src/components/Longline.tsx +107 -0
  13. package/templates/longline/src/components/Ocean.tsx +27 -0
  14. package/templates/longline/src/components/Radar.tsx +88 -0
  15. package/templates/longline/src/components/Referee.tsx +39 -0
  16. package/templates/longline/src/components/Scene.tsx +56 -0
  17. package/templates/longline/src/components/Sky.tsx +23 -0
  18. package/templates/longline/src/components/ocean-material.ts +143 -0
  19. package/templates/longline/src/components/round-context.ts +26 -0
  20. package/templates/longline/src/game/boat-control.ts +131 -0
  21. package/templates/longline/src/game/constants.ts +98 -0
  22. package/templates/longline/src/game/input.test.ts +83 -0
  23. package/templates/longline/src/game/input.ts +73 -0
  24. package/templates/longline/src/game/logic.test.ts +110 -0
  25. package/templates/longline/src/game/logic.ts +109 -0
  26. package/templates/longline/src/game/physics.test.ts +211 -0
  27. package/templates/longline/src/game/radar.ts +22 -0
  28. package/templates/longline/src/game/registry.ts +53 -0
  29. package/templates/longline/src/game/sea.ts +26 -0
  30. package/templates/longline/src/game/session.ts +6 -0
  31. package/templates/longline/src/game/simulation.test.ts +393 -0
  32. package/templates/longline/src/game/simulation.ts +137 -0
  33. package/templates/longline/src/game/store.test.ts +222 -0
  34. package/templates/longline/src/game/store.ts +195 -0
  35. package/templates/longline/src/game/test-world.ts +128 -0
  36. package/templates/longline/src/main.tsx +8 -0
  37. package/templates/longline/src/sfx.ts +50 -0
  38. package/templates/longline/src/styles.css +374 -0
  39. package/templates/longline/tsconfig.json +18 -0
  40. package/templates/longline/vite.config.ts +28 -0
@@ -0,0 +1,374 @@
1
+ :root {
2
+ --ink: #06243a;
3
+ --sea: #0a3a5c;
4
+ --foam: #f2f8fb;
5
+ --sun: #ffd23d;
6
+ --pink: #ff3d6e;
7
+ color-scheme: dark;
8
+ }
9
+
10
+ * {
11
+ box-sizing: border-box;
12
+ }
13
+
14
+ html,
15
+ body,
16
+ #root {
17
+ height: 100%;
18
+ margin: 0;
19
+ overflow: hidden;
20
+ background: #b9dbea;
21
+ font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
22
+ -webkit-tap-highlight-color: transparent;
23
+ overscroll-behavior: none;
24
+ }
25
+
26
+ .loading {
27
+ margin: 0;
28
+ padding: 2rem;
29
+ color: var(--ink);
30
+ font-weight: 700;
31
+ }
32
+
33
+ .stage {
34
+ position: fixed;
35
+ inset: 0;
36
+ touch-action: none;
37
+ }
38
+
39
+ .hud {
40
+ position: fixed;
41
+ inset: 0;
42
+ pointer-events: none;
43
+ color: var(--foam);
44
+ text-shadow: 0 1px 3px rgba(6, 36, 58, 0.7);
45
+ user-select: none;
46
+ -webkit-user-select: none;
47
+ }
48
+
49
+ .hud button {
50
+ pointer-events: auto;
51
+ font: inherit;
52
+ cursor: pointer;
53
+ }
54
+
55
+ .top {
56
+ position: absolute;
57
+ top: max(12px, env(safe-area-inset-top));
58
+ left: 16px;
59
+ right: 16px;
60
+ display: flex;
61
+ justify-content: space-between;
62
+ align-items: flex-start;
63
+ gap: 12px;
64
+ }
65
+
66
+ .score,
67
+ .tally {
68
+ min-width: 7rem;
69
+ display: flex;
70
+ flex-direction: column;
71
+ gap: 2px;
72
+ font-weight: 700;
73
+ }
74
+
75
+ .tally {
76
+ align-items: flex-end;
77
+ font-size: 0.95rem;
78
+ padding-right: 3.2rem;
79
+ }
80
+
81
+ .score .label {
82
+ font-size: 0.75rem;
83
+ letter-spacing: 0.12em;
84
+ text-transform: uppercase;
85
+ opacity: 0.85;
86
+ }
87
+
88
+ .score .value {
89
+ font-size: 2.2rem;
90
+ line-height: 1;
91
+ font-variant-numeric: tabular-nums;
92
+ }
93
+
94
+ .score .combo {
95
+ align-self: flex-start;
96
+ margin-top: 4px;
97
+ padding: 1px 8px;
98
+ border-radius: 999px;
99
+ background: var(--sun);
100
+ color: var(--ink);
101
+ text-shadow: none;
102
+ font-weight: 800;
103
+ }
104
+
105
+ .clock {
106
+ font-size: 2.6rem;
107
+ font-weight: 800;
108
+ font-variant-numeric: tabular-nums;
109
+ line-height: 1;
110
+ }
111
+
112
+ .clock.low {
113
+ color: var(--pink);
114
+ animation: pulse 1s ease-in-out infinite;
115
+ }
116
+
117
+ @keyframes pulse {
118
+ 50% {
119
+ transform: scale(1.12);
120
+ }
121
+ }
122
+
123
+ .toast {
124
+ position: absolute;
125
+ top: 26%;
126
+ left: 50%;
127
+ translate: -50% 0;
128
+ font-size: 2.4rem;
129
+ font-weight: 800;
130
+ color: var(--sun);
131
+ animation: toast 1.1s ease-out forwards;
132
+ }
133
+
134
+ @keyframes toast {
135
+ from {
136
+ opacity: 1;
137
+ transform: translateY(0) scale(0.8);
138
+ }
139
+ 20% {
140
+ transform: translateY(-6px) scale(1.15);
141
+ }
142
+ to {
143
+ opacity: 0;
144
+ transform: translateY(-46px) scale(1);
145
+ }
146
+ }
147
+
148
+ .radar {
149
+ position: absolute;
150
+ right: max(14px, env(safe-area-inset-right));
151
+ bottom: max(14px, env(safe-area-inset-bottom));
152
+ }
153
+
154
+ .warning {
155
+ position: absolute;
156
+ left: 50%;
157
+ bottom: 18%;
158
+ translate: -50% 0;
159
+ padding: 6px 16px;
160
+ border-radius: 999px;
161
+ background: var(--pink);
162
+ font-weight: 800;
163
+ opacity: 0;
164
+ transition: opacity 0.2s;
165
+ }
166
+
167
+ .mute {
168
+ position: absolute;
169
+ top: max(12px, env(safe-area-inset-top));
170
+ right: 14px;
171
+ width: 38px;
172
+ height: 38px;
173
+ border: 0;
174
+ border-radius: 50%;
175
+ background: rgba(6, 36, 58, 0.45);
176
+ font-size: 1.1rem;
177
+ line-height: 1;
178
+ color: var(--foam);
179
+ }
180
+
181
+ .touch {
182
+ position: absolute;
183
+ left: 0;
184
+ right: 0;
185
+ bottom: max(14px, env(safe-area-inset-bottom));
186
+ display: flex;
187
+ justify-content: space-between;
188
+ padding: 0 14px;
189
+ pointer-events: none;
190
+ }
191
+
192
+ .touch-side {
193
+ display: flex;
194
+ gap: 14px;
195
+ }
196
+
197
+ .touch button {
198
+ width: 76px;
199
+ height: 76px;
200
+ border: 2px solid rgba(255, 255, 255, 0.6);
201
+ border-radius: 50%;
202
+ background: rgba(6, 36, 58, 0.4);
203
+ color: var(--foam);
204
+ font-size: 1.6rem;
205
+ touch-action: none;
206
+ }
207
+
208
+ .touch button:active {
209
+ background: rgba(255, 210, 61, 0.55);
210
+ }
211
+
212
+ .panel {
213
+ position: absolute;
214
+ left: 50%;
215
+ top: 50%;
216
+ translate: -50% -50%;
217
+ width: min(92vw, 30rem);
218
+ padding: 1.6rem 1.6rem 1.3rem;
219
+ border-radius: 1.2rem;
220
+ background: rgba(6, 36, 58, 0.62);
221
+ backdrop-filter: blur(10px);
222
+ -webkit-backdrop-filter: blur(10px);
223
+ text-align: center;
224
+ pointer-events: auto;
225
+ box-shadow: 0 18px 50px rgba(6, 36, 58, 0.35);
226
+ }
227
+
228
+ .panel h1 {
229
+ margin: 0;
230
+ font-size: clamp(2.4rem, 9vw, 3.6rem);
231
+ letter-spacing: 0.04em;
232
+ text-transform: uppercase;
233
+ }
234
+
235
+ .panel h2 {
236
+ margin: 0;
237
+ font-size: 1.6rem;
238
+ }
239
+
240
+ .tag {
241
+ margin: 0.4rem 0 1.1rem;
242
+ font-size: 1.05rem;
243
+ }
244
+
245
+ .seas {
246
+ display: grid;
247
+ grid-template-columns: repeat(3, 1fr);
248
+ gap: 0.6rem;
249
+ }
250
+
251
+ .sea {
252
+ display: flex;
253
+ flex-direction: column;
254
+ gap: 2px;
255
+ padding: 0.6rem 0.4rem;
256
+ border: 2px solid rgba(255, 255, 255, 0.35);
257
+ border-radius: 0.8rem;
258
+ background: transparent;
259
+ color: var(--foam);
260
+ }
261
+
262
+ .sea span {
263
+ font-size: 0.72rem;
264
+ opacity: 0.85;
265
+ }
266
+
267
+ .sea.selected {
268
+ border-color: var(--sun);
269
+ background: rgba(255, 210, 61, 0.2);
270
+ }
271
+
272
+ .best {
273
+ margin: 0.9rem 0 0.2rem;
274
+ font-size: 0.95rem;
275
+ opacity: 0.9;
276
+ }
277
+
278
+ .newbest {
279
+ margin: 0.4rem 0;
280
+ font-size: 1.2rem;
281
+ font-weight: 800;
282
+ color: var(--sun);
283
+ }
284
+
285
+ .go,
286
+ .row button {
287
+ padding: 0.7rem 1.8rem;
288
+ border: 0;
289
+ border-radius: 999px;
290
+ background: var(--sun);
291
+ color: var(--ink);
292
+ font-size: 1.15rem;
293
+ font-weight: 800;
294
+ text-shadow: none;
295
+ }
296
+
297
+ .row {
298
+ display: flex;
299
+ justify-content: center;
300
+ gap: 0.8rem;
301
+ margin-top: 1rem;
302
+ }
303
+
304
+ .row button:not(.go) {
305
+ background: rgba(255, 255, 255, 0.85);
306
+ }
307
+
308
+ .go {
309
+ margin-top: 0.8rem;
310
+ }
311
+
312
+ .big {
313
+ font-size: 4rem;
314
+ font-weight: 800;
315
+ line-height: 1.1;
316
+ font-variant-numeric: tabular-nums;
317
+ }
318
+
319
+ .stats {
320
+ margin: 0.4rem 0 0;
321
+ }
322
+
323
+ .keys {
324
+ margin: 1.1rem 0 0;
325
+ font-size: 0.85rem;
326
+ opacity: 0.9;
327
+ }
328
+
329
+ .credit {
330
+ margin: 0.5rem 0 0;
331
+ font-size: 0.72rem;
332
+ opacity: 0.65;
333
+ }
334
+
335
+ kbd {
336
+ padding: 1px 6px;
337
+ border-radius: 5px;
338
+ background: rgba(255, 255, 255, 0.85);
339
+ color: var(--ink);
340
+ font: inherit;
341
+ font-weight: 800;
342
+ text-shadow: none;
343
+ }
344
+
345
+ .fatal {
346
+ position: fixed;
347
+ inset: 0;
348
+ display: grid;
349
+ place-content: center;
350
+ gap: 0.5rem;
351
+ padding: 2rem;
352
+ text-align: center;
353
+ color: var(--ink);
354
+ }
355
+
356
+ @media (max-width: 560px) {
357
+ .score .value {
358
+ font-size: 1.8rem;
359
+ }
360
+ .clock {
361
+ font-size: 2rem;
362
+ }
363
+ .tally {
364
+ padding-right: 2.8rem;
365
+ font-size: 0.8rem;
366
+ }
367
+ }
368
+
369
+ @media (prefers-reduced-motion: reduce) {
370
+ .toast,
371
+ .clock.low {
372
+ animation: none;
373
+ }
374
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "lib": ["ES2022", "DOM", "DOM.Iterable"],
6
+ "skipLibCheck": true,
7
+ "moduleResolution": "bundler",
8
+ "isolatedModules": true,
9
+ "moduleDetection": "force",
10
+ "jsx": "react-jsx",
11
+ "strict": true,
12
+ "noUncheckedIndexedAccess": true,
13
+ "noImplicitOverride": true,
14
+ "noEmit": true,
15
+ "types": ["node", "vite/client"]
16
+ },
17
+ "include": ["src", "vite.config.ts"]
18
+ }
@@ -0,0 +1,28 @@
1
+ import react from "@vitejs/plugin-react";
2
+ import { defineConfig } from "vite";
3
+
4
+ // One copy of each of these in the bundle: react-three-fiber, react-three-rapier and Kolmo's water hooks all talk to the
5
+ // same three, the same Rapier world and the same React.
6
+ export default defineConfig({
7
+ plugins: [react()],
8
+ resolve: {
9
+ dedupe: ["react", "react-dom", "three", "@react-three/fiber", "@react-three/rapier", "@dimforge/rapier3d-compat", "@pinkaphant/ecctrl"],
10
+ },
11
+ optimizeDeps: {
12
+ exclude: ["@dimforge/rapier3d-compat"],
13
+ },
14
+ build: {
15
+ chunkSizeWarningLimit: 2600,
16
+ rolldownOptions: {
17
+ output: {
18
+ codeSplitting: {
19
+ groups: [
20
+ { name: "three", test: /node_modules[\\/]three/ },
21
+ { name: "rapier", test: /node_modules[\\/](@dimforge[\\/]rapier3d-compat|@react-three[\\/]rapier)/ },
22
+ { name: "r3f", test: /node_modules[\\/]@react-three[\\/]fiber/ },
23
+ ],
24
+ },
25
+ },
26
+ },
27
+ },
28
+ });