@silkweaver/build 1.3.2 → 1.3.3
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/build.js +7 -4
- package/dist/object_format.d.ts +7 -6
- package/dist/object_format.js +11 -10
- package/package.json +1 -1
- package/templates/empty/.engine/engine.mjs +17557 -0
- package/templates/empty/.engine/version.json +4 -0
- package/templates/empty/project.json +2 -2
- package/templates/physics_ball/.engine/engine.mjs +277 -200
- package/templates/physics_ball/.engine/version.json +2 -2
- package/templates/physics_ball/objects/obj_ball.ts +5 -5
- package/templates/physics_ball/objects/obj_paddle.ts +8 -7
- package/templates/physics_ball/objects/obj_tracker.ts +1 -1
- package/templates/physics_ball/project.json +1 -1
- package/templates/platformer/.engine/engine.mjs +17557 -0
- package/templates/platformer/.engine/version.json +4 -0
- package/templates/platformer/objects/obj_platform.ts +0 -2
- package/templates/platformer/objects/obj_player.ts +33 -23
- package/templates/platformer/project.json +2 -2
- package/templates/topdown/.engine/engine.mjs +17557 -0
- package/templates/topdown/.engine/version.json +4 -0
- package/templates/topdown/objects/obj_player.ts +35 -37
- package/templates/topdown/project.json +2 -2
package/dist/build.js
CHANGED
|
@@ -218,10 +218,13 @@ async function generate_entry_code(project_folder, proj, asset_mode, engine_path
|
|
|
218
218
|
if ((inst.rotation ?? 0) !== 0)
|
|
219
219
|
lines.push(` ${v}.image_angle = ${inst.rotation}`);
|
|
220
220
|
lines.push(` ${v}.register_events()`);
|
|
221
|
-
|
|
222
|
-
//
|
|
221
|
+
// Queue the Create event (+ optional per-instance creation code) via the engine helper,
|
|
222
|
+
// which runs them under the active-instance context so `sw`/`inst` resolve inside.
|
|
223
223
|
if (inst.creation_code && inst.creation_code.trim()) {
|
|
224
|
-
lines.push(`
|
|
224
|
+
lines.push(` instance_queue_create(${v}, (function(this: any){\n${inst.creation_code}\n}).bind(${v}))`);
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
lines.push(` instance_queue_create(${v})`);
|
|
225
228
|
}
|
|
226
229
|
return lines.join('\n');
|
|
227
230
|
}).filter(Boolean).join('\n');
|
|
@@ -512,7 +515,7 @@ async function _load_sound(name: string, meta_url: string, base: string): Promis
|
|
|
512
515
|
// ── Bootstrap ───────────────────────────────────────────────────────────────
|
|
513
516
|
export default async function init(canvas: HTMLCanvasElement): Promise<void> {
|
|
514
517
|
renderer.init(canvas, ${proj.settings.windowWidth ?? 640}, ${proj.settings.windowHeight ?? 480})
|
|
515
|
-
|
|
518
|
+
renderer.set_clear_color(${JSON.stringify(proj.settings.displayColor ?? '#000000')}) // window/clear color (Game Settings)
|
|
516
519
|
game_loop.init_input(canvas)
|
|
517
520
|
|
|
518
521
|
// Load sprites
|
package/dist/object_format.d.ts
CHANGED
|
@@ -33,13 +33,14 @@ export interface object_model {
|
|
|
33
33
|
/** Extracts the object model from a class-file source. */
|
|
34
34
|
export declare function parse_object(src: string): object_model;
|
|
35
35
|
/**
|
|
36
|
-
* Collects
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
36
|
+
* Collects the object's OWN variables: declared instance fields *plus* members created/assigned at
|
|
37
|
+
* runtime via the `inst.` namespace inside any event (e.g. `inst.velocity = 0` in on_create, read in
|
|
38
|
+
* on_step). This drives `inst.` autocomplete, so a variable made in one event surfaces in all the
|
|
39
|
+
* others. Static fields (object metadata) and method/event names are excluded. The engine's built-in
|
|
40
|
+
* instance API is NOT collected here — it lives on `sw.` and is typed from the engine directly — so
|
|
41
|
+
* `this.x`/`sw.x` style writes never leak into the author's own-variable list.
|
|
41
42
|
*/
|
|
42
|
-
export declare function
|
|
43
|
+
export declare function object_vars(src: string): string[];
|
|
43
44
|
/**
|
|
44
45
|
* Sets (adds or updates) a static metadata field. `expr` is the raw initializer
|
|
45
46
|
* text (e.g. `'spr_player'`, `true`, `-5`, `obj_base`).
|
package/dist/object_format.js
CHANGED
|
@@ -46,7 +46,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
46
46
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
47
|
exports.EVENT_ORDER = exports.META_ORDER = void 0;
|
|
48
48
|
exports.parse_object = parse_object;
|
|
49
|
-
exports.
|
|
49
|
+
exports.object_vars = object_vars;
|
|
50
50
|
exports.set_static = set_static;
|
|
51
51
|
exports.remove_static = remove_static;
|
|
52
52
|
exports.set_field = set_field;
|
|
@@ -151,13 +151,14 @@ function _string_literal(node) {
|
|
|
151
151
|
return null;
|
|
152
152
|
}
|
|
153
153
|
/**
|
|
154
|
-
* Collects
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
154
|
+
* Collects the object's OWN variables: declared instance fields *plus* members created/assigned at
|
|
155
|
+
* runtime via the `inst.` namespace inside any event (e.g. `inst.velocity = 0` in on_create, read in
|
|
156
|
+
* on_step). This drives `inst.` autocomplete, so a variable made in one event surfaces in all the
|
|
157
|
+
* others. Static fields (object metadata) and method/event names are excluded. The engine's built-in
|
|
158
|
+
* instance API is NOT collected here — it lives on `sw.` and is typed from the engine directly — so
|
|
159
|
+
* `this.x`/`sw.x` style writes never leak into the author's own-variable list.
|
|
159
160
|
*/
|
|
160
|
-
function
|
|
161
|
+
function object_vars(src) {
|
|
161
162
|
const sf = _source(src);
|
|
162
163
|
const cls = _find_class(sf);
|
|
163
164
|
if (!cls)
|
|
@@ -170,14 +171,14 @@ function this_members(src) {
|
|
|
170
171
|
names.add(n);
|
|
171
172
|
}
|
|
172
173
|
}
|
|
173
|
-
// Any `
|
|
174
|
-
// blocks/closures — counts as an
|
|
174
|
+
// Any `inst.<name> = …` (or compound assignment) anywhere in the class body — including nested
|
|
175
|
+
// blocks/closures — counts as an author variable the user can reference elsewhere.
|
|
175
176
|
const visit = (node) => {
|
|
176
177
|
if (ts.isBinaryExpression(node)
|
|
177
178
|
&& node.operatorToken.kind >= ts.SyntaxKind.FirstAssignment
|
|
178
179
|
&& node.operatorToken.kind <= ts.SyntaxKind.LastAssignment
|
|
179
180
|
&& ts.isPropertyAccessExpression(node.left)
|
|
180
|
-
&& node.left.expression.
|
|
181
|
+
&& ts.isIdentifier(node.left.expression) && node.left.expression.text === 'inst'
|
|
181
182
|
&& ts.isIdentifier(node.left.name)) {
|
|
182
183
|
names.add(node.left.name.text);
|
|
183
184
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@silkweaver/build",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.3",
|
|
4
4
|
"description": "Silkweaver toolchain — compiles a project folder into a runnable game (HTML5 / desktop executable). Usable from a CLI or the IDE.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"license": "GPL-3.0",
|