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