dopaminejs 2.4.0 → 3.0.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.
Files changed (83) hide show
  1. package/README.md +40 -50
  2. package/dist/DataService-E4pGQ1V3.cjs +1 -0
  3. package/dist/DataService-MfmvkqXR.js +737 -0
  4. package/dist/core.cjs +1 -0
  5. package/dist/core.js +2 -0
  6. package/dist/dopamine.cjs +1 -37
  7. package/dist/dopamine.js +3 -858
  8. package/dist/games.cjs +1 -0
  9. package/dist/games.js +82 -0
  10. package/dist/host-CkRL74ck.js +814 -0
  11. package/dist/host-Pzb-QBPU.cjs +37 -0
  12. package/dist/style.css +395 -2
  13. package/dist/testing.cjs +1 -0
  14. package/dist/testing.js +474 -0
  15. package/package.json +28 -8
  16. package/spec/README.md +227 -0
  17. package/spec/VERSION +1 -0
  18. package/spec/fixtures/achievements.json +611 -0
  19. package/spec/fixtures/levels.json +421 -0
  20. package/spec/fixtures/merge.json +1739 -0
  21. package/spec/fixtures/migrate.json +916 -0
  22. package/spec/fixtures/scores.json +755 -0
  23. package/spec/fixtures/streaks.json +924 -0
  24. package/spec/schema.json +61 -0
  25. package/src/dopamine/audio/SoundManager.js +78 -24
  26. package/src/dopamine/core/DataService.js +25 -5
  27. package/src/dopamine/core/DopamineError.js +7 -0
  28. package/src/dopamine/core/RewardSystem.js +366 -368
  29. package/src/dopamine/core/achievements.js +49 -0
  30. package/src/dopamine/core/clock.js +11 -0
  31. package/src/dopamine/core/levels.js +4 -0
  32. package/src/dopamine/core/merge.js +68 -0
  33. package/src/dopamine/core/middleware.js +58 -0
  34. package/src/dopamine/core/store.js +261 -0
  35. package/src/dopamine/core/streaks.js +55 -0
  36. package/src/dopamine/effects/ParticleSystem.js +33 -3
  37. package/src/dopamine/feel/haptics.js +21 -0
  38. package/src/dopamine/feel/motion.js +9 -0
  39. package/src/dopamine/host.js +358 -0
  40. package/src/dopamine/ui/RewardUI.js +569 -0
  41. package/src/games.js +138 -0
  42. package/src/index.js +14 -33
  43. package/src/progression.js +16 -0
  44. package/src/testing.js +489 -0
  45. package/types/core.d.ts +35 -0
  46. package/types/games.d.ts +46 -0
  47. package/types/index.d.ts +348 -373
  48. package/types/testing.d.ts +96 -0
  49. package/dist/ScreenShake-9jgNXPS6.cjs +0 -1
  50. package/dist/ScreenShake-CLvO1wx4.js +0 -827
  51. package/dist/engine.cjs +0 -1
  52. package/dist/engine.js +0 -2
  53. package/src/core/Animator.js +0 -62
  54. package/src/core/Collider.js +0 -86
  55. package/src/core/Component.js +0 -38
  56. package/src/core/DopamineKernel.js +0 -170
  57. package/src/core/EventBus.js +0 -206
  58. package/src/core/Game.js +0 -90
  59. package/src/core/GameObject.js +0 -99
  60. package/src/core/PluginRegistry.js +0 -359
  61. package/src/core/Scene.js +0 -107
  62. package/src/core/Sprite.js +0 -51
  63. package/src/core/SystemRegistry.js +0 -263
  64. package/src/core/Vector2.js +0 -50
  65. package/src/dopamine/components/ParticleEmitter.js +0 -50
  66. package/src/dopamine/components/ScreenShake.js +0 -50
  67. package/src/dopamine/components/index.js +0 -2
  68. package/src/dopamine/index.js +0 -93
  69. package/src/dopamine/ui/GameUI.js +0 -420
  70. package/src/dopamine/utils/TextureGenerator.js +0 -90
  71. package/src/engine.js +0 -38
  72. package/src/interfaces/IAudioSystem.js +0 -58
  73. package/src/interfaces/IParticleSystem.js +0 -51
  74. package/src/interfaces/IPhysicsSystem.js +0 -52
  75. package/src/interfaces/ISystem.js +0 -48
  76. package/src/interfaces/index.js +0 -7
  77. package/src/renderer/Renderer.js +0 -45
  78. package/src/systems/Director.js +0 -34
  79. package/src/systems/Input.js +0 -81
  80. package/src/systems/Loader.js +0 -48
  81. package/src/systems/Physics.js +0 -210
  82. package/src/systems/Ticker.js +0 -91
  83. package/src/systems/deprecate.js +0 -38
@@ -1,420 +0,0 @@
1
- /**
2
- * UI Components for Dopamine-Driven Games
3
- * Reusable UI elements for XP bars, achievement popups, level-up screens, etc.
4
- */
5
-
6
- const OVERLAY_ID = 'game-ui-overlay';
7
-
8
- export class GameUI {
9
- constructor(particleSystem) {
10
- this.particleSystem = particleSystem;
11
- this.container = null;
12
- this.xpBar = null;
13
- this.levelDisplay = null;
14
- this.streakDisplay = null;
15
-
16
- // Everything this instance put in the DOM or scheduled, so destroy()
17
- // can take it all back out again.
18
- this._timers = new Set();
19
- this._detached = [];
20
-
21
- this.init();
22
- }
23
-
24
- /**
25
- * Initialize UI overlay
26
- */
27
- init() {
28
- // Create main container
29
- this.container = document.createElement('div');
30
- this.container.className = 'game-ui-overlay';
31
-
32
- // The stylesheet targets #game-ui-overlay. Claim the id only if it is
33
- // free, so a second instance cannot produce a duplicate id.
34
- if (!document.getElementById(OVERLAY_ID)) {
35
- this.container.id = OVERLAY_ID;
36
- }
37
-
38
- this.container.innerHTML = `
39
- <div class="game-ui-top-bar">
40
- <div class="level-badge">
41
- <span class="level-label">LVL</span>
42
- <span class="level-number">1</span>
43
- </div>
44
-
45
- <div class="xp-container">
46
- <div class="xp-bar-bg">
47
- <div class="xp-bar-fill" style="width: 0%"></div>
48
- </div>
49
- <div class="xp-text">0 / 100 XP</div>
50
- </div>
51
-
52
- <div class="streak-badge">
53
- <span class="streak-icon">🔥</span>
54
- <span class="streak-number">1</span>
55
- </div>
56
- </div>
57
- `;
58
-
59
- // Popups are decorative and short-lived, so a screen reader would
60
- // miss them. This region repeats them as plain text.
61
- this.liveRegion = document.createElement('div');
62
- this.liveRegion.className = 'dopamine-live-region';
63
- this.liveRegion.setAttribute('aria-live', 'polite');
64
- this.liveRegion.setAttribute('role', 'status');
65
- Object.assign(this.liveRegion.style, {
66
- position: 'absolute',
67
- width: '1px',
68
- height: '1px',
69
- overflow: 'hidden',
70
- clipPath: 'inset(50%)',
71
- whiteSpace: 'nowrap'
72
- });
73
- this.container.appendChild(this.liveRegion);
74
-
75
- document.body.appendChild(this.container);
76
-
77
- // Scoped to this instance. Document-wide getElementById would make a
78
- // second GameUI silently rebind every element to the first one's DOM.
79
- this.levelBadge = this.container.querySelector('.level-badge');
80
- this.streakBadge = this.container.querySelector('.streak-badge');
81
- this.xpBar = this.container.querySelector('.xp-bar-fill');
82
- this.xpText = this.container.querySelector('.xp-text');
83
- this.levelDisplay = this.container.querySelector('.level-number');
84
- this.streakDisplay = this.container.querySelector('.streak-number');
85
- }
86
-
87
- /**
88
- * setTimeout that destroy() can cancel.
89
- * @private
90
- */
91
- _defer(fn, delay) {
92
- const id = setTimeout(() => {
93
- this._timers.delete(id);
94
- fn();
95
- }, delay);
96
- this._timers.add(id);
97
- return id;
98
- }
99
-
100
- /**
101
- * Append a transient element and remember it for cleanup.
102
- * @private
103
- */
104
- _mount(el) {
105
- document.body.appendChild(el);
106
- this._detached.push(el);
107
- return el;
108
- }
109
-
110
- /**
111
- * Repeat a popup as text for assistive technology.
112
- * @private
113
- */
114
- _announce(message) {
115
- if (this.liveRegion) {
116
- this.liveRegion.textContent = message;
117
- }
118
- }
119
-
120
- /**
121
- * Replay a CSS animation by clearing it for one tick.
122
- * @private
123
- */
124
- _replayAnimation(el, animation) {
125
- if (!el) return;
126
- el.style.animation = 'none';
127
- this._defer(() => { el.style.animation = animation; }, 10);
128
- }
129
-
130
- /**
131
- * Update XP bar
132
- * @param {number} current - XP held right now
133
- * @param {number} needed - XP still required for the next level
134
- * @param {number} total - XP total that marks the next level
135
- * @param {number} [progress] - Position within the current level, 0 to 1.
136
- * Without it the bar falls back to current / total, which is lifetime
137
- * XP and starts every level after the first partly full.
138
- */
139
- updateXP(current, needed, total, progress) {
140
- const fraction = Number.isFinite(progress)
141
- ? progress
142
- : (total > 0 ? current / total : 0);
143
- this.xpBar.style.width = `${Math.max(0, Math.min(100, fraction * 100))}%`;
144
- this.xpText.textContent = `${current} / ${total} XP`;
145
-
146
- this._replayAnimation(this.xpBar, 'xp-pulse 0.3s ease-out');
147
- }
148
-
149
- /**
150
- * Update level display
151
- */
152
- updateLevel(level) {
153
- this.levelDisplay.textContent = level;
154
- this._replayAnimation(this.levelBadge, 'level-pulse 0.5s ease-out');
155
- }
156
-
157
- /**
158
- * Update streak display
159
- */
160
- updateStreak(days) {
161
- this.streakDisplay.textContent = days;
162
-
163
- // Change color based on streak
164
- if (days >= 7) {
165
- this.streakBadge.style.background = 'linear-gradient(135deg, #ff6b00 0%, #ff4400 100%)';
166
- } else if (days >= 3) {
167
- this.streakBadge.style.background = 'linear-gradient(135deg, #ff8800 0%, #ff6b00 100%)';
168
- } else {
169
- this.streakBadge.style.background = '';
170
- }
171
- }
172
-
173
- /**
174
- * Show achievement unlocked popup
175
- *
176
- * `icon` is rendered as HTML by design (documented in ARCHITECTURE.md, so
177
- * games can pass an <img> or inline SVG). Every other field is game state
178
- * and could carry a player-supplied or server-supplied string, so it goes
179
- * in as text.
180
- */
181
- showAchievement(achievement) {
182
- const popup = document.createElement('div');
183
- popup.className = 'achievement-popup';
184
- popup.innerHTML = `
185
- <div class="achievement-shine"></div>
186
- <div class="achievement-content">
187
- <div class="achievement-icon"></div>
188
- <div class="achievement-info">
189
- <div class="achievement-title">Achievement Unlocked!</div>
190
- <div class="achievement-name"></div>
191
- <div class="achievement-desc"></div>
192
- <div class="achievement-xp"></div>
193
- </div>
194
- </div>
195
- `;
196
-
197
- popup.querySelector('.achievement-icon').innerHTML = achievement.icon ?? '';
198
- popup.querySelector('.achievement-name').textContent = achievement.name ?? '';
199
- popup.querySelector('.achievement-desc').textContent = achievement.description ?? '';
200
- popup.querySelector('.achievement-xp').textContent = `+${achievement.xp ?? 0} XP`;
201
-
202
- this._mount(popup);
203
- this._announce(`Achievement unlocked: ${achievement.name ?? ''}`);
204
-
205
- // Trigger confetti at popup location
206
- this._defer(() => {
207
- const rect = popup.getBoundingClientRect();
208
- this.particleSystem.confetti(rect.left + rect.width / 2, rect.top + rect.height / 2, 40);
209
- }, 300);
210
-
211
- // Remove after animation
212
- this._defer(() => {
213
- popup.style.animation = 'slideOut 0.3s ease-in forwards';
214
- this._defer(() => this._remove(popup), 300);
215
- }, 4000);
216
- }
217
-
218
- /**
219
- * Show level up screen
220
- */
221
- showLevelUp(oldLevel, newLevel) {
222
- const overlay = document.createElement('div');
223
- overlay.className = 'level-up-overlay';
224
- overlay.innerHTML = `
225
- <div class="level-up-content">
226
- <div class="level-up-title">LEVEL UP!</div>
227
- <div class="level-up-number"></div>
228
- <div class="level-up-subtitle">Amazing progress!</div>
229
- </div>
230
- `;
231
- overlay.querySelector('.level-up-number').textContent = newLevel;
232
-
233
- this._mount(overlay);
234
- this._announce(`Level up: ${newLevel}`);
235
-
236
- // Fireworks effect
237
- this._defer(() => {
238
- for (let i = 0; i < 5; i++) {
239
- this._defer(() => {
240
- const x = Math.random() * window.innerWidth;
241
- const y = Math.random() * window.innerHeight * 0.6;
242
- this.particleSystem.confetti(x, y, 30);
243
- }, i * 200);
244
- }
245
- }, 300);
246
-
247
- // Remove after 3 seconds
248
- this._defer(() => {
249
- overlay.style.opacity = '0';
250
- this._defer(() => this._remove(overlay), 500);
251
- }, 2500);
252
- }
253
-
254
- /**
255
- * Show floating text (e.g., "+50 XP", "COMBO!")
256
- */
257
- showFloatingText(text, x, y, color = '#ffd700', size = '24px') {
258
- const floater = document.createElement('div');
259
- floater.className = 'floating-text';
260
- floater.textContent = text;
261
- floater.style.left = x + 'px';
262
- floater.style.top = y + 'px';
263
- floater.style.color = color;
264
- floater.style.fontSize = size;
265
-
266
- this._mount(floater);
267
-
268
- this._defer(() => this._remove(floater), 2000);
269
- }
270
-
271
- /**
272
- * Show combo multiplier
273
- */
274
- showCombo(multiplier, x, y) {
275
- this.showFloatingText(`${multiplier}× COMBO!`, x, y, '#ff6b6b', '32px');
276
- this.particleSystem.fire(x, y, 20);
277
- }
278
-
279
- /**
280
- * Show "near miss" indicator
281
- */
282
- showNearMiss(x, y) {
283
- this.showFloatingText('CLOSE CALL!', x, y, '#45b7d1', '20px');
284
- this.particleSystem.sparkle(x, y, 15, '#45b7d1');
285
- }
286
-
287
- /**
288
- * Show lucky moment (random multiplier)
289
- */
290
- showLuckyMoment(multiplier, x, y) {
291
- this.showFloatingText(`LUCKY ${multiplier}×!`, x, y, '#ffd700', '36px');
292
- this.particleSystem.starBurst(x, y, 12);
293
- this.particleSystem.confetti(x, y, 25);
294
- }
295
-
296
- /**
297
- * Show generic notification
298
- */
299
- showNotification(message, type = 'normal') {
300
- const x = window.innerWidth / 2;
301
- const y = window.innerHeight / 3;
302
-
303
- // The message is shown as written. showLuckyMoment and showCombo
304
- // expect a multiplier and would wrap it in "LUCKY ...×!".
305
- if (type === 'legendary') {
306
- this.showFloatingText(message, x, y, '#ffd700', '36px');
307
- this.particleSystem.starBurst(x, y, 12);
308
- this.particleSystem.confetti(x, y, 25);
309
- } else if (type === 'rare') {
310
- this.showFloatingText(message, x, y, '#ff6b6b', '32px');
311
- this.particleSystem.fire(x, y, 20);
312
- } else {
313
- this.showFloatingText(message, x, y, '#fff', '24px');
314
- }
315
-
316
- this._announce(message);
317
- }
318
-
319
- /**
320
- * Show Game Over Summary
321
- *
322
- * @param {Object} data
323
- * @param {number|string} data.score - Final score
324
- * @param {Object} [data.metrics] - Label/value pairs listed under the score
325
- * @param {Function} [data.onReplay] - Replay button handler (default: reload)
326
- * @param {Function} [data.onExit] - Exit button handler (button hidden if omitted)
327
- */
328
- showSummary(data) {
329
- const overlay = document.createElement('div');
330
- overlay.className = 'message-box';
331
- overlay.style.display = 'flex';
332
- overlay.style.position = 'absolute';
333
- overlay.style.top = '50%';
334
- overlay.style.left = '50%';
335
- overlay.style.transform = 'translate(-50%, -50%)';
336
- overlay.style.zIndex = '1000';
337
-
338
- const heading = document.createElement('h1');
339
- heading.textContent = 'Game Over';
340
-
341
- const score = document.createElement('div');
342
- score.className = 'summary-score';
343
- score.style.cssText = 'font-size: 3rem; font-weight: bold; color: #e06020; margin: 10px 0;';
344
- score.textContent = data.score;
345
-
346
- const metrics = document.createElement('div');
347
- metrics.className = 'summary-metrics';
348
- metrics.style.cssText = 'width: 100%; margin-bottom: 20px;';
349
-
350
- for (const [key, value] of Object.entries(data.metrics || {})) {
351
- const row = document.createElement('div');
352
- row.style.cssText = 'display:flex;justify-content:space-between;width:100%';
353
-
354
- const label = document.createElement('span');
355
- label.textContent = `${key}:`;
356
-
357
- const amount = document.createElement('strong');
358
- amount.textContent = value;
359
-
360
- row.append(label, amount);
361
- metrics.appendChild(row);
362
- }
363
-
364
- overlay.append(heading, score, metrics);
365
-
366
- // addEventListener rather than an onclick attribute: inline handlers
367
- // are blocked by any script-src CSP without 'unsafe-inline'.
368
- const replay = document.createElement('button');
369
- replay.className = 'btn';
370
- replay.textContent = 'Play Again';
371
- replay.addEventListener('click', data.onReplay || (() => window.location.reload()));
372
- overlay.appendChild(replay);
373
-
374
- if (data.onExit) {
375
- const exit = document.createElement('button');
376
- exit.className = 'btn';
377
- exit.textContent = 'Exit';
378
- exit.style.cssText = 'margin-top: 10px; background: #543847;';
379
- exit.addEventListener('click', data.onExit);
380
- overlay.appendChild(exit);
381
- }
382
-
383
- this._mount(overlay);
384
- return overlay;
385
- }
386
-
387
- /**
388
- * @private
389
- */
390
- _remove(el) {
391
- el.remove();
392
- const i = this._detached.indexOf(el);
393
- if (i > -1) this._detached.splice(i, 1);
394
- }
395
-
396
- /**
397
- * Tear down the overlay, any transient popups, and all pending timers.
398
- */
399
- destroy() {
400
- for (const id of this._timers) {
401
- clearTimeout(id);
402
- }
403
- this._timers.clear();
404
-
405
- for (const el of this._detached) {
406
- el.remove();
407
- }
408
- this._detached = [];
409
-
410
- this.container?.remove();
411
- this.container = null;
412
- this.liveRegion = null;
413
- this.xpBar = null;
414
- this.xpText = null;
415
- this.levelBadge = null;
416
- this.streakBadge = null;
417
- this.levelDisplay = null;
418
- this.streakDisplay = null;
419
- }
420
- }
@@ -1,90 +0,0 @@
1
- /**
2
- * Generates procedural textures for prototyping.
3
- */
4
- export class TextureGenerator {
5
- static createGround(width, height, color = '#333') {
6
- const canvas = document.createElement('canvas');
7
- canvas.width = width;
8
- canvas.height = height;
9
- const ctx = canvas.getContext('2d');
10
-
11
- ctx.fillStyle = color;
12
- ctx.fillRect(0, 0, width, height);
13
-
14
- // Noise / Grit
15
- for (let i = 0; i < 1000; i++) {
16
- ctx.fillStyle = Math.random() > 0.5 ? '#444' : '#222';
17
- const size = Math.random() * 4 + 2;
18
- ctx.fillRect(Math.random() * width, Math.random() * height, size, size);
19
- }
20
-
21
- // Grid lines overlay (faint)
22
- ctx.strokeStyle = 'rgba(255,255,255,0.05)';
23
- ctx.lineWidth = 2;
24
- ctx.beginPath();
25
- for (let i = 0; i <= width; i += 64) {
26
- ctx.moveTo(i, 0); ctx.lineTo(i, height);
27
- }
28
- for (let i = 0; i <= height; i += 64) {
29
- ctx.moveTo(0, i); ctx.lineTo(width, i);
30
- }
31
- ctx.stroke();
32
-
33
- return canvas;
34
- }
35
-
36
- static createCharacterSheet(colorBody, colorDetail) {
37
- // Create a 4-frame walk cycle strip (Vertical or Horizontal)
38
- // Let's do Horizontal: 64x64 frames, 4 frames -> 256x64 image
39
- const cellW = 64;
40
- const cellH = 64;
41
- const canvas = document.createElement('canvas');
42
- canvas.width = cellW * 4;
43
- canvas.height = cellH;
44
- const ctx = canvas.getContext('2d');
45
-
46
- for (let i = 0; i < 4; i++) {
47
- const x = i * cellW;
48
- const y = 0;
49
- const cx = x + cellW / 2;
50
- const cy = y + cellH / 2;
51
-
52
- // -- Frame Animation Variances --
53
- // Bobbing effect
54
- const bob = (i % 2 === 0) ? 0 : -2;
55
- // Leg swing (simulated by shape change or just simple offset)
56
- const legOffset = (i === 1) ? 5 : (i === 3 ? -5 : 0);
57
-
58
- // Body
59
- ctx.fillStyle = colorBody;
60
- ctx.beginPath();
61
- ctx.arc(cx, cy + bob, 20, 0, Math.PI * 2);
62
- ctx.fill();
63
-
64
- // Shoulders/Hands (Top Down)
65
- ctx.fillStyle = colorDetail;
66
- ctx.beginPath();
67
- ctx.arc(cx - 15, cy + bob + legOffset, 8, 0, Math.PI * 2); // Left hand
68
- ctx.arc(cx + 15, cy + bob - legOffset, 8, 0, Math.PI * 2); // Right hand
69
- ctx.fill();
70
-
71
- // Head/Helmet
72
- ctx.fillStyle = adjustColor(colorBody, -20);
73
- ctx.beginPath();
74
- ctx.arc(cx, cy + bob, 15, 0, Math.PI * 2);
75
- ctx.fill();
76
-
77
- // Gun (if soldier)
78
- if (colorDetail === '#333') { // Hacky check
79
- ctx.fillStyle = '#000';
80
- ctx.fillRect(cx + 10, cy + bob - 5, 25, 6);
81
- }
82
- }
83
-
84
- return canvas;
85
- }
86
- }
87
-
88
- function adjustColor(color, amount) {
89
- return color; // Placeholder for color darkening logic
90
- }
package/src/engine.js DELETED
@@ -1,38 +0,0 @@
1
- /**
2
- * Engine subpath export — `import { Game, Scene } from 'dopaminejs/engine'`
3
- *
4
- * The game engine that DopamineJS is built on. Use this subpath if your project
5
- * only needs the entity/component system, renderer, or physics, and not the
6
- * progression mechanics (RewardSystem, GameUI, DataService).
7
- *
8
- * The root `dopaminejs` export continues to re-export everything, so nothing breaks.
9
- * This subpath makes the README's distinction between the engine and the progression
10
- * layer real in code and gives bundlers a clear surface to tree-shake against.
11
- */
12
-
13
- // Entity / component system
14
- export { Game } from './core/Game.js';
15
- export { Scene } from './core/Scene.js';
16
- export { GameObject } from './core/GameObject.js';
17
- export { Component } from './core/Component.js';
18
- export { Vector2 } from './core/Vector2.js';
19
- export { Collider } from './core/Collider.js';
20
- export { Sprite } from './core/Sprite.js';
21
- export { Animator } from './core/Animator.js';
22
-
23
- // Kernel and plugin infrastructure
24
- export { DopamineKernel } from './core/DopamineKernel.js';
25
- export { EventBus } from './core/EventBus.js';
26
- export { SystemRegistry } from './core/SystemRegistry.js';
27
- export { PluginRegistry } from './core/PluginRegistry.js';
28
-
29
- // Built-in systems
30
- export { Renderer } from './renderer/Renderer.js';
31
- export { Ticker } from './systems/Ticker.js';
32
- export { Loader, GlobalLoader } from './systems/Loader.js';
33
- export { Input, GlobalInput } from './systems/Input.js';
34
- export { Director } from './systems/Director.js';
35
- export { Physics, GlobalPhysics } from './systems/Physics.js';
36
-
37
- // Engine-level components
38
- export { ParticleEmitter, ScreenShake } from './dopamine/components/index.js';
@@ -1,58 +0,0 @@
1
- import { ISystem } from './ISystem.js';
2
-
3
- /**
4
- * IAudioSystem - Interface for audio implementations
5
- *
6
- * Allows different audio engines (Web Audio, Howler.js, etc.) to be swapped
7
- */
8
- export const IAudioSystem = {
9
- ...ISystem,
10
-
11
- /**
12
- * Register a sound with a key
13
- * @param {string} key - Sound identifier
14
- * @param {string} url - Path to audio file
15
- */
16
- registerSound(key, url) { },
17
-
18
- /**
19
- * Preload multiple sounds
20
- * @param {Object} soundMap - Map of key -> url
21
- * @returns {Promise<void>}
22
- */
23
- preloadSounds(soundMap) { },
24
-
25
- /**
26
- * Play a sound by key
27
- * @param {string} key - Sound identifier
28
- * @param {Object} options - Playback options (volume, loop, etc.)
29
- */
30
- play(key, options) { },
31
-
32
- /**
33
- * Play a synthesized tone
34
- * @param {number} frequency - Frequency in Hz
35
- * @param {number} duration - Duration in seconds
36
- * @param {string} type - Waveform type ('sine', 'square', etc.)
37
- * @param {number} volume - Volume (0-1)
38
- */
39
- playTone(frequency, duration, type, volume) { },
40
-
41
- /**
42
- * Stop a playing sound
43
- * @param {string} key - Sound identifier
44
- */
45
- stop(key) { },
46
-
47
- /**
48
- * Toggle mute state
49
- * @returns {boolean} - New mute state
50
- */
51
- toggleMute() { },
52
-
53
- /**
54
- * Set master volume
55
- * @param {number} volume - Volume (0-1)
56
- */
57
- setVolume(volume) { },
58
- };
@@ -1,51 +0,0 @@
1
- import { ISystem } from './ISystem.js';
2
-
3
- /**
4
- * IParticleSystem - Interface for particle system implementations
5
- *
6
- * Allows different renderers (Canvas, WebGL, custom) to be swapped
7
- */
8
- export const IParticleSystem = {
9
- ...ISystem,
10
-
11
- /**
12
- * Register a sprite for particles
13
- * @param {string} key - Sprite identifier
14
- * @param {string} url - Path to image
15
- */
16
- registerSprite(key, url) { },
17
-
18
- /**
19
- * Register a custom effect
20
- * @param {string} name - Effect name
21
- * @param {Function} callback - Effect function (x, y, ...args) => void
22
- */
23
- registerEffect(name, callback) { },
24
-
25
- /**
26
- * Play a registered effect
27
- * @param {string} name - Effect name
28
- * @param {number} x - X position
29
- * @param {number} y - Y position
30
- * @param {...any} args - Additional arguments
31
- */
32
- play(name, x, y, ...args) { },
33
-
34
- /**
35
- * Emit particles with custom configuration
36
- * @param {Object} config - Particle configuration
37
- */
38
- emit(config) { },
39
-
40
- /**
41
- * Clear all particles
42
- */
43
- clear() { },
44
-
45
- // Built-in effects (optional, but recommended)
46
- confetti(x, y, count) { },
47
- coinShower(x, y, count) { },
48
- sparkle(x, y, count, color) { },
49
- fire(x, y, count) { },
50
- starBurst(x, y, count) { },
51
- };