dopaminejs 2.5.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 (81) 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 -1
  5. package/dist/core.js +2 -2
  6. package/dist/dopamine.cjs +1 -37
  7. package/dist/dopamine.js +3 -635
  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 +24 -9
  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 +54 -24
  26. package/src/dopamine/core/DopamineError.js +7 -0
  27. package/src/dopamine/core/RewardSystem.js +323 -373
  28. package/src/dopamine/core/achievements.js +49 -0
  29. package/src/dopamine/core/clock.js +11 -0
  30. package/src/dopamine/core/levels.js +4 -0
  31. package/src/dopamine/core/merge.js +68 -0
  32. package/src/dopamine/core/middleware.js +58 -0
  33. package/src/dopamine/core/store.js +261 -0
  34. package/src/dopamine/core/streaks.js +55 -0
  35. package/src/dopamine/effects/ParticleSystem.js +30 -0
  36. package/src/dopamine/host.js +358 -0
  37. package/src/dopamine/ui/{GameUI.js → RewardUI.js} +166 -202
  38. package/src/games.js +138 -0
  39. package/src/index.js +11 -34
  40. package/src/progression.js +3 -0
  41. package/src/testing.js +489 -0
  42. package/types/core.d.ts +9 -1
  43. package/types/games.d.ts +46 -0
  44. package/types/index.d.ts +291 -384
  45. package/types/testing.d.ts +96 -0
  46. package/dist/DataService-BPXCldpo.cjs +0 -1
  47. package/dist/DataService-CH9_gv_8.js +0 -398
  48. package/dist/ScreenShake-9jgNXPS6.cjs +0 -1
  49. package/dist/ScreenShake-CLvO1wx4.js +0 -827
  50. package/dist/engine.cjs +0 -1
  51. package/dist/engine.js +0 -2
  52. package/src/core/Animator.js +0 -62
  53. package/src/core/Collider.js +0 -86
  54. package/src/core/Component.js +0 -38
  55. package/src/core/DopamineKernel.js +0 -170
  56. package/src/core/EventBus.js +0 -206
  57. package/src/core/Game.js +0 -90
  58. package/src/core/GameObject.js +0 -99
  59. package/src/core/PluginRegistry.js +0 -359
  60. package/src/core/Scene.js +0 -107
  61. package/src/core/Sprite.js +0 -51
  62. package/src/core/SystemRegistry.js +0 -263
  63. package/src/core/Vector2.js +0 -50
  64. package/src/dopamine/components/ParticleEmitter.js +0 -50
  65. package/src/dopamine/components/ScreenShake.js +0 -50
  66. package/src/dopamine/components/index.js +0 -2
  67. package/src/dopamine/index.js +0 -93
  68. package/src/dopamine/utils/TextureGenerator.js +0 -90
  69. package/src/engine.js +0 -38
  70. package/src/interfaces/IAudioSystem.js +0 -58
  71. package/src/interfaces/IParticleSystem.js +0 -51
  72. package/src/interfaces/IPhysicsSystem.js +0 -52
  73. package/src/interfaces/ISystem.js +0 -48
  74. package/src/interfaces/index.js +0 -7
  75. package/src/renderer/Renderer.js +0 -45
  76. package/src/systems/Director.js +0 -34
  77. package/src/systems/Input.js +0 -81
  78. package/src/systems/Loader.js +0 -48
  79. package/src/systems/Physics.js +0 -210
  80. package/src/systems/Ticker.js +0 -91
  81. package/src/systems/deprecate.js +0 -38
package/dist/games.js ADDED
@@ -0,0 +1,82 @@
1
+ //#region src/games.js
2
+ var e = {
3
+ combo: "{n}× COMBO!",
4
+ nearMiss: "CLOSE CALL!",
5
+ luckyMoment: "LUCKY {n}×!",
6
+ gameOver: "Game Over",
7
+ playAgain: "Play Again",
8
+ exit: "Exit"
9
+ }, t = (e, t) => Object.prototype.hasOwnProperty.call(e, t), n = {
10
+ jump: (e) => e.playTone(400, .1, "square", .2),
11
+ score: (e, t) => {
12
+ e.playTone(800, .15, "sine", .25), t(() => e.playTone(1e3, .15, "sine", .25), 50);
13
+ },
14
+ gameover: (e, t) => {
15
+ e.playTone(300, .2, "sawtooth", .3), t(() => e.playTone(200, .2, "sawtooth", .3), 100), t(() => e.playTone(150, .3, "sawtooth", .3), 200);
16
+ }
17
+ }, r = (e, t, n) => {
18
+ let r = document.createElement(e);
19
+ return t !== void 0 && (r.textContent = t), n && (r.style.cssText = n), r;
20
+ };
21
+ function i(i) {
22
+ let a = { ...e }, o = typeof i == "object" && i && t(i, "text") ? i.text : null;
23
+ for (let n of Object.keys(e)) typeof o == "object" && o && t(o, n) && typeof o[n] == "string" && (a[n] = o[n]);
24
+ let s = null, c = /* @__PURE__ */ new Set(), l = (e, t, n, r, i, o) => {
25
+ let c = a[e].replace("{n}", () => String(t));
26
+ c !== "" && s.parts.ui.text({
27
+ text: c,
28
+ x: n,
29
+ y: r,
30
+ color: i,
31
+ size: o
32
+ });
33
+ }, u = (e, t, n, r) => s.parts.particles?.burst(e, {
34
+ x: t,
35
+ y: n
36
+ }, r), d = {
37
+ name: "games",
38
+ version: "1.0.0",
39
+ api: 3,
40
+ requires: ["ui"],
41
+ combo(e, t, n) {
42
+ s && (l("combo", e, t, n, "#ff6b6b", "32px"), u("fire", t, n, { count: 20 }));
43
+ },
44
+ nearMiss(e, t) {
45
+ s && (l("nearMiss", "", e, t, "#45b7d1", "20px"), u("sparkle", e, t, {
46
+ count: 15,
47
+ color: "#45b7d1"
48
+ }));
49
+ },
50
+ luckyMoment(e, t, n) {
51
+ s && (l("luckyMoment", e, t, n, "#ffd700", "36px"), u("stars", t, n, { count: 12 }), u("confetti", t, n, { count: 25 }));
52
+ },
53
+ summary(e) {
54
+ if (!s || !s.env.hasDom || typeof e != "object" || !e) return null;
55
+ let t = r("div", void 0, "display:flex;flex-direction:column;align-items:center;position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);z-index:1000");
56
+ t.className = "message-box", a.gameOver !== "" && t.append(r("h1", a.gameOver)), t.append(r("div", e.score, "font-size:3rem;font-weight:bold;color:#e06020;margin:10px 0"));
57
+ let n = r("div", void 0, "width:100%;margin-bottom:20px"), i = e.metrics !== null && typeof e.metrics == "object" ? e.metrics : {};
58
+ for (let [e, t] of Object.entries(i)) {
59
+ let i = r("div", void 0, "display:flex;justify-content:space-between;width:100%");
60
+ i.append(r("span", `${e}:`), r("strong", t)), n.append(i);
61
+ }
62
+ t.append(n);
63
+ let o = (e, n) => {
64
+ let i = r("button", e);
65
+ i.className = "btn", i.addEventListener("click", n), t.append(i);
66
+ };
67
+ return a.playAgain !== "" && o(a.playAgain, typeof e.onReplay == "function" ? e.onReplay : () => window.location.reload()), typeof e.onExit == "function" && a.exit !== "" && o(a.exit, e.onExit), document.body.append(t), c.add(t), t;
68
+ },
69
+ install(e) {
70
+ s = e;
71
+ let t = Object.keys(n).map((e) => s.parts.sound?.register?.(e, n[e]));
72
+ return e.expose(d), () => {
73
+ for (let e of t) e?.();
74
+ for (let e of c) e.remove();
75
+ c.clear(), s = null;
76
+ };
77
+ }
78
+ };
79
+ return d;
80
+ }
81
+ //#endregion
82
+ export { i as gameFeedback };