brick-engine-js 1.0.4 → 1.0.6

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 (33) hide show
  1. package/dist/app.js +18 -15
  2. package/dist/app.js.map +1 -1
  3. package/dist/bootstrap.d.ts +0 -1
  4. package/dist/brick-engine.js +616 -8
  5. package/dist/brick-engine.js.map +1 -1
  6. package/dist/css/brick-engine.bundle.css +824 -0
  7. package/dist/css/brick-engine.bundle.css.map +1 -0
  8. package/dist/docs/GAME_DEVELOPER_GUIDE.html +1 -1
  9. package/dist/docs/brick-engine-guide.html +1 -1
  10. package/dist/docs/getting-started.html +1 -1
  11. package/dist/docs/jsdoc_standard.html +1 -1
  12. package/dist/docs/publishing.html +1 -1
  13. package/dist/docs/reference/interfaces/modules/Session.html +1 -1
  14. package/dist/docs/reference/modules/GameMenu.html +1 -1
  15. package/dist/docs/reference/modules/GameSession.html +1 -1
  16. package/dist/docs/reference/modules/InitialStateSnapshot.html +1 -1
  17. package/dist/docs/reference/modules/SessionModal.html +1 -1
  18. package/dist/docs/testing_best_practices.html +1 -1
  19. package/dist/index.d.ts +1 -0
  20. package/package.json +1 -1
  21. package/public/docs/GAME_DEVELOPER_GUIDE.html +1 -1
  22. package/public/docs/brick-engine-guide.html +1 -1
  23. package/public/docs/getting-started.html +1 -1
  24. package/public/docs/jsdoc_standard.html +1 -1
  25. package/public/docs/publishing.html +1 -1
  26. package/public/docs/reference/interfaces/modules/Session.html +1 -1
  27. package/public/docs/reference/modules/GameMenu.html +1 -1
  28. package/public/docs/reference/modules/GameSession.html +1 -1
  29. package/public/docs/reference/modules/InitialStateSnapshot.html +1 -1
  30. package/public/docs/reference/modules/SessionModal.html +1 -1
  31. package/public/docs/testing_best_practices.html +1 -1
  32. package/dist/config/styles.d.ts +0 -0
  33. package/dist/index.test.d.ts +0 -1
@@ -1,7 +1,6 @@
1
1
  import p5 from 'p5';
2
2
  import Game from './core/Game';
3
3
  import GameView from './view/GameView';
4
- import './config/styles';
5
4
  /**
6
5
  * Represents a constructor for a game class.
7
6
  *
@@ -1,19 +1,183 @@
1
1
  (function webpackUniversalModuleDefinition(root, factory) {
2
2
  if(typeof exports === 'object' && typeof module === 'object')
3
- module.exports = factory();
3
+ module.exports = factory(require("p5"));
4
4
  else if(typeof define === 'function' && define.amd)
5
- define([], factory);
5
+ define(["p5"], factory);
6
6
  else if(typeof exports === 'object')
7
- exports["BrickEngine"] = factory();
7
+ exports["BrickEngine"] = factory(require("p5"));
8
8
  else
9
- root["BrickEngine"] = factory();
10
- })(self, () => {
9
+ root["BrickEngine"] = factory(root["p5"]);
10
+ })(self, (__WEBPACK_EXTERNAL_MODULE__991__) => {
11
11
  return /******/ (() => { // webpackBootstrap
12
- /******/ "use strict";
13
- /******/ // The require scope
14
- /******/ var __webpack_require__ = {};
12
+ /******/ var __webpack_modules__ = ({
13
+
14
+ /***/ 902
15
+ (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
16
+
17
+ "use strict";
18
+ __webpack_require__.r(__webpack_exports__);
19
+ // extracted by mini-css-extract-plugin
20
+
21
+
22
+ /***/ },
23
+
24
+ /***/ 35
25
+ (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
26
+
27
+ "use strict";
28
+ __webpack_require__.r(__webpack_exports__);
29
+ // extracted by mini-css-extract-plugin
30
+
31
+
32
+ /***/ },
33
+
34
+ /***/ 287
35
+ (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
36
+
37
+ "use strict";
38
+ __webpack_require__.r(__webpack_exports__);
39
+ // extracted by mini-css-extract-plugin
40
+
41
+
42
+ /***/ },
43
+
44
+ /***/ 949
45
+ (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
46
+
47
+ "use strict";
48
+ __webpack_require__.r(__webpack_exports__);
49
+ // extracted by mini-css-extract-plugin
50
+
51
+
52
+ /***/ },
53
+
54
+ /***/ 545
55
+ (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
56
+
57
+ "use strict";
58
+ __webpack_require__.r(__webpack_exports__);
59
+ // extracted by mini-css-extract-plugin
60
+
61
+
62
+ /***/ },
63
+
64
+ /***/ 623
65
+ (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
66
+
67
+ "use strict";
68
+ __webpack_require__.r(__webpack_exports__);
69
+ // extracted by mini-css-extract-plugin
70
+
71
+
72
+ /***/ },
73
+
74
+ /***/ 839
75
+ (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
76
+
77
+ "use strict";
78
+ __webpack_require__.r(__webpack_exports__);
79
+ // extracted by mini-css-extract-plugin
80
+
81
+
82
+ /***/ },
83
+
84
+ /***/ 881
85
+ (module, __unused_webpack_exports, __webpack_require__) {
86
+
87
+ var map = {
88
+ "./body.css": 902,
89
+ "./buttons.css": 35,
90
+ "./debugger.css": 287,
91
+ "./sessionModal.css": 949,
92
+ "./sourceCodeAndCommands.css": 545,
93
+ "./splash.css": 623,
94
+ "./theme.css": 839
95
+ };
96
+
97
+
98
+ function webpackContext(req) {
99
+ var id = webpackContextResolve(req);
100
+ return __webpack_require__(id);
101
+ }
102
+ function webpackContextResolve(req) {
103
+ if(!__webpack_require__.o(map, req)) {
104
+ var e = new Error("Cannot find module '" + req + "'");
105
+ e.code = 'MODULE_NOT_FOUND';
106
+ throw e;
107
+ }
108
+ return map[req];
109
+ }
110
+ webpackContext.keys = function webpackContextKeys() {
111
+ return Object.keys(map);
112
+ };
113
+ webpackContext.resolve = webpackContextResolve;
114
+ module.exports = webpackContext;
115
+ webpackContext.id = 881;
116
+
117
+ /***/ },
118
+
119
+ /***/ 589
120
+ (module) {
121
+
122
+ function webpackEmptyContext(req) {
123
+ var e = new Error("Cannot find module '" + req + "'");
124
+ e.code = 'MODULE_NOT_FOUND';
125
+ throw e;
126
+ }
127
+ webpackEmptyContext.keys = () => ([]);
128
+ webpackEmptyContext.resolve = webpackEmptyContext;
129
+ webpackEmptyContext.id = 589;
130
+ module.exports = webpackEmptyContext;
131
+
132
+ /***/ },
133
+
134
+ /***/ 991
135
+ (module) {
136
+
137
+ "use strict";
138
+ module.exports = __WEBPACK_EXTERNAL_MODULE__991__;
139
+
140
+ /***/ }
141
+
142
+ /******/ });
143
+ /************************************************************************/
144
+ /******/ // The module cache
145
+ /******/ var __webpack_module_cache__ = {};
146
+ /******/
147
+ /******/ // The require function
148
+ /******/ function __webpack_require__(moduleId) {
149
+ /******/ // Check if module is in cache
150
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
151
+ /******/ if (cachedModule !== undefined) {
152
+ /******/ return cachedModule.exports;
153
+ /******/ }
154
+ /******/ // Create a new module (and put it into the cache)
155
+ /******/ var module = __webpack_module_cache__[moduleId] = {
156
+ /******/ // no module.id needed
157
+ /******/ // no module.loaded needed
158
+ /******/ exports: {}
159
+ /******/ };
160
+ /******/
161
+ /******/ // Execute the module function
162
+ /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
163
+ /******/
164
+ /******/ // Return the exports of the module
165
+ /******/ return module.exports;
166
+ /******/ }
15
167
  /******/
16
168
  /************************************************************************/
169
+ /******/ /* webpack/runtime/compat get default export */
170
+ /******/ (() => {
171
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
172
+ /******/ __webpack_require__.n = (module) => {
173
+ /******/ var getter = module && module.__esModule ?
174
+ /******/ () => (module['default']) :
175
+ /******/ () => (module);
176
+ /******/ __webpack_require__.d(getter, { a: getter });
177
+ /******/ return getter;
178
+ /******/ };
179
+ /******/ })();
180
+ /******/
17
181
  /******/ /* webpack/runtime/define property getters */
18
182
  /******/ (() => {
19
183
  /******/ // define getter functions for harmony exports
@@ -44,6 +208,9 @@ return /******/ (() => { // webpackBootstrap
44
208
  /******/
45
209
  /************************************************************************/
46
210
  var __webpack_exports__ = {};
211
+ // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
212
+ (() => {
213
+ "use strict";
47
214
  // ESM COMPAT FLAG
48
215
  __webpack_require__.r(__webpack_exports__);
49
216
 
@@ -59,6 +226,7 @@ __webpack_require__.d(__webpack_exports__, {
59
226
  GameView: () => (/* reexport */ view_GameView),
60
227
  Sound: () => (/* reexport */ Sound),
61
228
  StateProperty: () => (/* reexport */ StateProperty),
229
+ bootstrap: () => (/* reexport */ bootstrap),
62
230
  configs: () => (/* reexport */ configs)
63
231
  });
64
232
 
@@ -4425,6 +4593,443 @@ var GameView = /** @class */ (function () {
4425
4593
  }());
4426
4594
  /* harmony default export */ const view_GameView = (GameView);
4427
4595
 
4596
+ // EXTERNAL MODULE: external "p5"
4597
+ var external_p5_ = __webpack_require__(991);
4598
+ var external_p5_default = /*#__PURE__*/__webpack_require__.n(external_p5_);
4599
+ ;// ./src/menu/GameRepository.ts
4600
+ var GameRepository_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
4601
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4602
+ return new (P || (P = Promise))(function (resolve, reject) {
4603
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
4604
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
4605
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
4606
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
4607
+ });
4608
+ };
4609
+ var GameRepository_generator = (undefined && undefined.__generator) || function (thisArg, body) {
4610
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
4611
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
4612
+ function verb(n) { return function (v) { return step([n, v]); }; }
4613
+ function step(op) {
4614
+ if (f) throw new TypeError("Generator is already executing.");
4615
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
4616
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
4617
+ if (y = 0, t) op = [op[0] & 2, t.value];
4618
+ switch (op[0]) {
4619
+ case 0: case 1: t = op; break;
4620
+ case 4: _.label++; return { value: op[1], done: false };
4621
+ case 5: _.label++; y = op[1]; op = [0]; continue;
4622
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
4623
+ default:
4624
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
4625
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
4626
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
4627
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
4628
+ if (t[2]) _.ops.pop();
4629
+ _.trys.pop(); continue;
4630
+ }
4631
+ op = body.call(thisArg, _);
4632
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
4633
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
4634
+ }
4635
+ };
4636
+ var GameRepository = /** @class */ (function () {
4637
+ function GameRepository() {
4638
+ this._games = [{ id: 'loading', name: 'Loading...', url: '' }];
4639
+ this.fetchGames();
4640
+ }
4641
+ GameRepository.prototype.fetchGames = function () {
4642
+ return GameRepository_awaiter(this, void 0, void 0, function () {
4643
+ var supabaseUrl, anonKey, headers, response, data, error_1;
4644
+ return GameRepository_generator(this, function (_a) {
4645
+ switch (_a.label) {
4646
+ case 0:
4647
+ _a.trys.push([0, 3, , 4]);
4648
+ supabaseUrl = "http://127.0.0.1:54321" || 0;
4649
+ anonKey = false || '';
4650
+ headers = {};
4651
+ if (anonKey) {
4652
+ headers['Authorization'] = "Bearer ".concat(anonKey);
4653
+ }
4654
+ return [4 /*yield*/, fetch("".concat(supabaseUrl, "/functions/v1/list"), {
4655
+ headers: headers,
4656
+ })];
4657
+ case 1:
4658
+ response = _a.sent();
4659
+ if (!response.ok) {
4660
+ throw new Error("Error fetching games: ".concat(response.statusText));
4661
+ }
4662
+ return [4 /*yield*/, response.json()];
4663
+ case 2:
4664
+ data = _a.sent();
4665
+ if (data && data.games && data.games.length > 0) {
4666
+ this._games = data.games.map(function (game) { return ({
4667
+ id: game.id,
4668
+ name: game.name,
4669
+ url: game.url,
4670
+ }); });
4671
+ }
4672
+ else {
4673
+ this._games = [{ id: 'empty', name: 'Not found', url: '' }];
4674
+ }
4675
+ return [3 /*break*/, 4];
4676
+ case 3:
4677
+ error_1 = _a.sent();
4678
+ console.error(error_1);
4679
+ this._games = [{ id: 'error', name: 'Error', url: '' }];
4680
+ return [3 /*break*/, 4];
4681
+ case 4: return [2 /*return*/];
4682
+ }
4683
+ });
4684
+ });
4685
+ };
4686
+ Object.defineProperty(GameRepository.prototype, "games", {
4687
+ get: function () {
4688
+ return Object.freeze(this._games);
4689
+ },
4690
+ enumerable: false,
4691
+ configurable: true
4692
+ });
4693
+ return GameRepository;
4694
+ }());
4695
+ /* harmony default export */ const menu_GameRepository = (GameRepository);
4696
+
4697
+ ;// ./src/menu/manager/GameManager.ts
4698
+ var GameManager_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
4699
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4700
+ return new (P || (P = Promise))(function (resolve, reject) {
4701
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
4702
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
4703
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
4704
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
4705
+ });
4706
+ };
4707
+ var GameManager_generator = (undefined && undefined.__generator) || function (thisArg, body) {
4708
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
4709
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
4710
+ function verb(n) { return function (v) { return step([n, v]); }; }
4711
+ function step(op) {
4712
+ if (f) throw new TypeError("Generator is already executing.");
4713
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
4714
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
4715
+ if (y = 0, t) op = [op[0] & 2, t.value];
4716
+ switch (op[0]) {
4717
+ case 0: case 1: t = op; break;
4718
+ case 4: _.label++; return { value: op[1], done: false };
4719
+ case 5: _.label++; y = op[1]; op = [0]; continue;
4720
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
4721
+ default:
4722
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
4723
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
4724
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
4725
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
4726
+ if (t[2]) _.ops.pop();
4727
+ _.trys.pop(); continue;
4728
+ }
4729
+ op = body.call(thisArg, _);
4730
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
4731
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
4732
+ }
4733
+ };
4734
+ var GameManager = /** @class */ (function () {
4735
+ function GameManager() {
4736
+ }
4737
+ GameManager.prototype.handleGameSwitch = function (entry, actualGame) {
4738
+ return GameManager_awaiter(this, void 0, void 0, function () {
4739
+ var gameInstance, e_1;
4740
+ return GameManager_generator(this, function (_a) {
4741
+ switch (_a.label) {
4742
+ case 0:
4743
+ _a.trys.push([0, 2, , 3]);
4744
+ return [4 /*yield*/, this._loadGameScript(entry.url)];
4745
+ case 1:
4746
+ _a.sent();
4747
+ // Client must define window.BrickEngineGame
4748
+ console.log('Game instance defined on window.BrickEngineGame by client project: ', window.BrickEngineGame);
4749
+ if (window.BrickEngineGame) {
4750
+ gameInstance = new window.BrickEngineGame(actualGame.p, actualGame.view);
4751
+ console.log('Game loaded: ', entry.name);
4752
+ console.log('Game loaded: ', entry.name);
4753
+ // Set properly the Game ID using the GameRepository fetch ID
4754
+ gameInstance.gameId = entry.id;
4755
+ console.log('Switching to game');
4756
+ actualGame.switchGame(gameInstance);
4757
+ console.log('Game switched');
4758
+ // Cleanup
4759
+ console.log('Cleaning up window.BrickEngineGame');
4760
+ delete window.BrickEngineGame;
4761
+ }
4762
+ else {
4763
+ console.error('Game bundle loaded but window.BrickEngineGame was not set.');
4764
+ }
4765
+ return [3 /*break*/, 3];
4766
+ case 2:
4767
+ e_1 = _a.sent();
4768
+ console.error('Failed to load game:', e_1);
4769
+ return [3 /*break*/, 3];
4770
+ case 3: return [2 /*return*/];
4771
+ }
4772
+ });
4773
+ });
4774
+ };
4775
+ GameManager.prototype._loadGameScript = function (url) {
4776
+ return new Promise(function (resolve, reject) {
4777
+ var existingScript = document.getElementById('game-client-script');
4778
+ if (existingScript) {
4779
+ existingScript.remove();
4780
+ }
4781
+ var script = document.createElement('script');
4782
+ script.src = url;
4783
+ script.id = 'game-client-script';
4784
+ script.onload = function () { return resolve(); };
4785
+ script.onerror = function () { return reject(new Error("Failed to load script ".concat(url))); };
4786
+ document.head.appendChild(script);
4787
+ });
4788
+ };
4789
+ return GameManager;
4790
+ }());
4791
+ /* harmony default export */ const manager_GameManager = (GameManager);
4792
+
4793
+ ;// ./src/menu/GameMenu.ts
4794
+ var GameMenu_extends = (undefined && undefined.__extends) || (function () {
4795
+ var extendStatics = function (d, b) {
4796
+ extendStatics = Object.setPrototypeOf ||
4797
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
4798
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
4799
+ return extendStatics(d, b);
4800
+ };
4801
+ return function (d, b) {
4802
+ if (typeof b !== "function" && b !== null)
4803
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
4804
+ extendStatics(d, b);
4805
+ function __() { this.constructor = d; }
4806
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
4807
+ };
4808
+ })();
4809
+
4810
+
4811
+
4812
+
4813
+ var GameMenu = /** @class */ (function (_super) {
4814
+ GameMenu_extends(GameMenu, _super);
4815
+ function GameMenu(p, view) {
4816
+ var _this = _super.call(this, p, view) || this;
4817
+ _this._gameSelectionPointer = 0;
4818
+ _this._isLoading = false;
4819
+ _this._gameRepository = new menu_GameRepository();
4820
+ _this._gameManager = new manager_GameManager();
4821
+ return _this;
4822
+ }
4823
+ GameMenu.prototype.setupGame = function () {
4824
+ var _this = this;
4825
+ var _a = this.modules, state = _a.state, control = _a.control, sound = _a.sound;
4826
+ control.subscribe(ControlKey.ACTION, ControlEventType.PRESSED, function () {
4827
+ if (_this._isLoading)
4828
+ return;
4829
+ if (state.isStarted()) {
4830
+ var selectedGame = _this._gameRepository.games[_this._gameSelectionPointer];
4831
+ _this._gameManager.handleGameSwitch(selectedGame, _this);
4832
+ }
4833
+ });
4834
+ control.subscribe(ControlKey.LEFT, ControlEventType.PRESSED, function () {
4835
+ if (state.isPlaying()) {
4836
+ sound.play(Sound.ACTION_1);
4837
+ if (_this._gameSelectionPointer === 0) {
4838
+ _this._gameSelectionPointer = _this._gameRepository.games.length - 1;
4839
+ }
4840
+ else {
4841
+ _this._gameSelectionPointer--;
4842
+ }
4843
+ }
4844
+ });
4845
+ control.subscribe(ControlKey.RIGHT, ControlEventType.PRESSED, function () {
4846
+ if (state.isPlaying()) {
4847
+ sound.play(Sound.ACTION_1);
4848
+ if (_this._gameSelectionPointer === _this._gameRepository.games.length - 1) {
4849
+ _this._gameSelectionPointer = 0;
4850
+ }
4851
+ else {
4852
+ _this._gameSelectionPointer++;
4853
+ }
4854
+ }
4855
+ });
4856
+ state.subscribe(StateProperty.ON, function (on) {
4857
+ if (on) {
4858
+ sound.play(Sound.START_THEME);
4859
+ }
4860
+ });
4861
+ };
4862
+ GameMenu.prototype.update = function () { };
4863
+ GameMenu.prototype.render = function () {
4864
+ var text = this.modules.text;
4865
+ var p = this.p;
4866
+ p.push();
4867
+ text.setTextSize(FontSize.LARGE);
4868
+ text.setActiveText();
4869
+ text.setTextAlign(FontAlign.CENTER, FontVerticalAlign.BOTTOM);
4870
+ text.textOnDisplay('Menu', { x: 0.5, y: 0.15 });
4871
+ text.setTextSize(FontSize.SMALL);
4872
+ text.textOnDisplay('Choose a game and', { x: 0.5, y: 0.25 });
4873
+ text.textOnDisplay('Press action to play', { x: 0.5, y: 0.32 });
4874
+ text.setTextAlign(FontAlign.RIGHT, FontVerticalAlign.BOTTOM);
4875
+ text.textOnDisplay('<', { x: 0.1, y: 0.54 });
4876
+ text.setTextAlign(FontAlign.LEFT, FontVerticalAlign.BOTTOM);
4877
+ text.textOnDisplay('>', { x: 0.9, y: 0.54 });
4878
+ text.setTextSize(FontSize.MEDIUM);
4879
+ text.setTextAlign(FontAlign.CENTER, FontVerticalAlign.BOTTOM);
4880
+ text.textOnDisplay(this._gameRepository.games[this._gameSelectionPointer].name, { x: 0.5, y: 0.55 });
4881
+ text.setTextSize(FontSize.EXTRA_SMALL);
4882
+ text.setTextAlign(FontAlign.LEFT, FontVerticalAlign.BOTTOM);
4883
+ text.textOnDisplay('Left: Previous option', { x: 0.05, y: 0.78 });
4884
+ text.textOnDisplay('Right: Next option', { x: 0.05, y: 0.84 });
4885
+ text.textOnDisplay('Action: Select', { x: 0.05, y: 0.9 });
4886
+ p.pop();
4887
+ };
4888
+ GameMenu.prototype.drawTitleScreen = function () {
4889
+ var text = this.modules.text;
4890
+ this.p.push();
4891
+ text.setTextSize(FontSize.LARGE);
4892
+ text.setActiveText();
4893
+ text.setTextAlign(FontAlign.CENTER, FontVerticalAlign.TOP);
4894
+ text.textOnDisplay('Menu', { x: 0.5, y: 0.15 });
4895
+ text.setTextSize(FontSize.SMALL);
4896
+ text.textOnDisplay('Wellcome to your', { x: 0.5, y: 0.25 });
4897
+ text.textOnDisplay('favorite brick game', { x: 0.5, y: 0.32 });
4898
+ text.textOnDisplay('simulator!', { x: 0.5, y: 0.39 });
4899
+ text.textOnDisplay('Press start', { x: 0.5, y: 0.66 });
4900
+ text.textOnDisplay('to continue.', { x: 0.5, y: 0.72 });
4901
+ this.p.pop();
4902
+ };
4903
+ GameMenu.prototype.drawGameOverScreen = function () {
4904
+ // Menu doesn't have a game over screen
4905
+ };
4906
+ return GameMenu;
4907
+ }(core_Game));
4908
+ /* harmony default export */ const menu_GameMenu = (GameMenu);
4909
+
4910
+ ;// ./src/menu/GameMenuSingleton.ts
4911
+ /**
4912
+ * Singleton manager for the Game Menu instance.
4913
+ *
4914
+ * This class provides a centralized point to store and retrieve the Game Menu
4915
+ * instance, facilitating access for game switching and system-level actions.
4916
+ */
4917
+ var GameMenuSingleton = /** @class */ (function () {
4918
+ function GameMenuSingleton() {
4919
+ }
4920
+ /**
4921
+ * Sets the global instance of the Game Menu.
4922
+ *
4923
+ * @param {GameMenu} instance - The Game Menu instance.
4924
+ * @returns {void}
4925
+ */
4926
+ GameMenuSingleton.setInstance = function (instance) {
4927
+ GameMenuSingleton._instance = instance;
4928
+ };
4929
+ /**
4930
+ * Retrieves the global instance of the Game Menu.
4931
+ *
4932
+ * @returns {GameMenu} The Game Menu instance.
4933
+ */
4934
+ GameMenuSingleton.getInstance = function () {
4935
+ return GameMenuSingleton._instance;
4936
+ };
4937
+ /**
4938
+ * Checks if the Game Menu instance has been initialized.
4939
+ *
4940
+ * @returns {boolean} True if the instance exists, false otherwise.
4941
+ */
4942
+ GameMenuSingleton.hasInstance = function () {
4943
+ return GameMenuSingleton._instance !== undefined;
4944
+ };
4945
+ return GameMenuSingleton;
4946
+ }());
4947
+ /* harmony default export */ const menu_GameMenuSingleton = (GameMenuSingleton);
4948
+
4949
+ ;// ./src/bootstrap.ts
4950
+
4951
+
4952
+
4953
+
4954
+
4955
+ var _game;
4956
+ var _p;
4957
+ /**
4958
+ * Handles the logic for switching between different games.
4959
+ *
4960
+ * This handler unbinds controls from the current game, sets up the new game,
4961
+ * propagates shared state, and rebinds controls to the new game's controller.
4962
+ *
4963
+ * @param {Game} newGame - The new game instance to switch to.
4964
+ * @returns {void}
4965
+ */
4966
+ var _switchHandler = function (newGame) {
4967
+ try {
4968
+ // Unbind the previous game controls
4969
+ _game.view.unbindControls();
4970
+ // Propagate the switch handler to the new game
4971
+ newGame.propagateSwitchHandler(_game);
4972
+ // Set the new game
4973
+ newGame.setup();
4974
+ var _a = newGame.modules, control = _a.control, state_1 = _a.state;
4975
+ // Update debugger
4976
+ newGame.view.updateDebuggerGameModules(newGame.modules);
4977
+ // Bind the new game controls
4978
+ newGame.view.bindControls(control);
4979
+ state_1.turnOn();
4980
+ // Setup exit and power buttons
4981
+ if (menu_GameMenuSingleton.hasInstance() && newGame !== menu_GameMenuSingleton.getInstance()) {
4982
+ control.subscribe(ControlKey.EXIT, ControlEventType.PRESSED, function () {
4983
+ newGame.switchGame(menu_GameMenuSingleton.getInstance());
4984
+ });
4985
+ control.subscribe(ControlKey.POWER, ControlEventType.PRESSED, function () {
4986
+ newGame.switchGame(menu_GameMenuSingleton.getInstance());
4987
+ state_1.turnOff();
4988
+ });
4989
+ }
4990
+ _game = newGame;
4991
+ }
4992
+ catch (error) {
4993
+ console.error('Error switching game:', error);
4994
+ }
4995
+ _p.loop();
4996
+ };
4997
+ /**
4998
+ * Bootstraps the brick engine and initializes the game.
4999
+ *
5000
+ * This is the main entry point for the engine's execution. It creates a new p5 instance,
5001
+ * initializes the view, and sets up the initial game provided by the caller.
5002
+ *
5003
+ * @param {ClientGameConstructor} ClientGame - The constructor of the game to be loaded.
5004
+ * @returns {p5} The p5 instance.
5005
+ */
5006
+ function bootstrap(ClientGame) {
5007
+ if (typeof __webpack_require__(589).context === 'function') {
5008
+ __webpack_require__(881);
5009
+ }
5010
+ return new (external_p5_default())(function (p) {
5011
+ _p = p;
5012
+ var view = new view_GameView(p, document.body);
5013
+ if (ClientGame === menu_GameMenu) {
5014
+ _game = new ClientGame(p, view);
5015
+ menu_GameMenuSingleton.setInstance(_game);
5016
+ }
5017
+ else {
5018
+ _game = new ClientGame(p, view);
5019
+ }
5020
+ _game.setSwitchHandler(_switchHandler);
5021
+ p.setup = function () {
5022
+ _game.setup();
5023
+ _game.view.setupDebugger(_game.modules);
5024
+ _game.view.setupSessionModal();
5025
+ };
5026
+ p.draw = function () {
5027
+ _game.draw();
5028
+ _game.view.updateDebugger();
5029
+ };
5030
+ });
5031
+ }
5032
+
4428
5033
  ;// ./src/index.ts
4429
5034
  // Library Exports Only
4430
5035
 
@@ -4436,6 +5041,9 @@ var GameView = /** @class */ (function () {
4436
5041
 
4437
5042
 
4438
5043
 
5044
+
5045
+ })();
5046
+
4439
5047
  /******/ return __webpack_exports__;
4440
5048
  /******/ })()
4441
5049
  ;