goudengine 0.0.826 → 0.0.828

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 (52) hide show
  1. package/README.md +18 -0
  2. package/dist/generated/errors.g.d.ts +37 -0
  3. package/dist/generated/errors.g.d.ts.map +1 -0
  4. package/dist/generated/errors.g.js +148 -0
  5. package/dist/generated/errors.g.js.map +1 -0
  6. package/dist/generated/index.g.d.ts +3 -2
  7. package/dist/generated/index.g.d.ts.map +1 -1
  8. package/dist/generated/index.g.js +13 -1
  9. package/dist/generated/index.g.js.map +1 -1
  10. package/dist/generated/node/index.g.d.ts +122 -2
  11. package/dist/generated/node/index.g.d.ts.map +1 -1
  12. package/dist/generated/node/index.g.js +160 -1
  13. package/dist/generated/node/index.g.js.map +1 -1
  14. package/dist/generated/types/engine.g.d.ts +134 -0
  15. package/dist/generated/types/engine.g.d.ts.map +1 -1
  16. package/dist/generated/types/input.g.d.ts +38 -0
  17. package/dist/generated/types/input.g.d.ts.map +1 -1
  18. package/dist/generated/types/input.g.js +45 -1
  19. package/dist/generated/types/input.g.js.map +1 -1
  20. package/dist/generated/types/math.g.d.ts +4 -0
  21. package/dist/generated/types/math.g.d.ts.map +1 -1
  22. package/dist/generated/types/math.g.js +4 -0
  23. package/dist/generated/types/math.g.js.map +1 -1
  24. package/dist/web/generated/types/engine.g.d.ts +134 -0
  25. package/dist/web/generated/types/engine.g.d.ts.map +1 -1
  26. package/dist/web/generated/types/input.g.d.ts +38 -0
  27. package/dist/web/generated/types/input.g.d.ts.map +1 -1
  28. package/dist/web/generated/types/input.g.js +44 -0
  29. package/dist/web/generated/types/input.g.js.map +1 -1
  30. package/dist/web/generated/types/math.g.d.ts +4 -0
  31. package/dist/web/generated/types/math.g.d.ts.map +1 -1
  32. package/dist/web/generated/types/math.g.js +4 -0
  33. package/dist/web/generated/types/math.g.js.map +1 -1
  34. package/dist/web/generated/web/errors.g.d.ts +37 -0
  35. package/dist/web/generated/web/errors.g.d.ts.map +1 -0
  36. package/dist/web/generated/web/errors.g.js +136 -0
  37. package/dist/web/generated/web/errors.g.js.map +1 -0
  38. package/dist/web/generated/web/index.g.d.ts +91 -2
  39. package/dist/web/generated/web/index.g.d.ts.map +1 -1
  40. package/dist/web/generated/web/index.g.js +144 -13
  41. package/dist/web/generated/web/index.g.js.map +1 -1
  42. package/goud-engine-node.darwin-arm64.node +0 -0
  43. package/goud-engine-node.darwin-x64.node +0 -0
  44. package/goud-engine-node.linux-x64-gnu.node +0 -0
  45. package/goud-engine-node.win32-x64-msvc.node +0 -0
  46. package/index.d.ts +24 -0
  47. package/index.js +53 -52
  48. package/package.json +1 -1
  49. package/wasm/goud_engine.d.ts +231 -60
  50. package/wasm/goud_engine.js +621 -57
  51. package/wasm/goud_engine_bg.wasm +0 -0
  52. package/wasm/goud_engine_bg.wasm.d.ts +93 -34
@@ -1,28 +1,97 @@
1
1
  /* @ts-self-types="./goud_engine.d.ts" */
2
2
 
3
- /**
4
- * Chroma subsampling format
5
- * @enum {0 | 1 | 2 | 3}
6
- */
7
- export const ChromaSampling = Object.freeze({
3
+ export class WasmContact {
4
+ static __wrap(ptr) {
5
+ ptr = ptr >>> 0;
6
+ const obj = Object.create(WasmContact.prototype);
7
+ obj.__wbg_ptr = ptr;
8
+ WasmContactFinalization.register(obj, obj.__wbg_ptr, obj);
9
+ return obj;
10
+ }
11
+ __destroy_into_raw() {
12
+ const ptr = this.__wbg_ptr;
13
+ this.__wbg_ptr = 0;
14
+ WasmContactFinalization.unregister(this);
15
+ return ptr;
16
+ }
17
+ free() {
18
+ const ptr = this.__destroy_into_raw();
19
+ wasm.__wbg_wasmcontact_free(ptr, 0);
20
+ }
8
21
  /**
9
- * Both vertically and horizontally subsampled.
22
+ * @returns {number}
23
+ */
24
+ get normal_x() {
25
+ const ret = wasm.__wbg_get_wasmcontact_normal_x(this.__wbg_ptr);
26
+ return ret;
27
+ }
28
+ /**
29
+ * @returns {number}
30
+ */
31
+ get normal_y() {
32
+ const ret = wasm.__wbg_get_wasmcontact_normal_y(this.__wbg_ptr);
33
+ return ret;
34
+ }
35
+ /**
36
+ * @returns {number}
37
+ */
38
+ get penetration() {
39
+ const ret = wasm.__wbg_get_wasmcontact_penetration(this.__wbg_ptr);
40
+ return ret;
41
+ }
42
+ /**
43
+ * @returns {number}
44
+ */
45
+ get point_x() {
46
+ const ret = wasm.__wbg_get_wasmcontact_point_x(this.__wbg_ptr);
47
+ return ret;
48
+ }
49
+ /**
50
+ * @returns {number}
51
+ */
52
+ get point_y() {
53
+ const ret = wasm.__wbg_get_wasmcontact_point_y(this.__wbg_ptr);
54
+ return ret;
55
+ }
56
+ /**
57
+ * @param {number} arg0
58
+ */
59
+ set normal_x(arg0) {
60
+ wasm.__wbg_set_wasmcontact_normal_x(this.__wbg_ptr, arg0);
61
+ }
62
+ /**
63
+ * @param {number} arg0
10
64
  */
11
- Cs420: 0, "0": "Cs420",
65
+ set normal_y(arg0) {
66
+ wasm.__wbg_set_wasmcontact_normal_y(this.__wbg_ptr, arg0);
67
+ }
12
68
  /**
13
- * Horizontally subsampled.
69
+ * @param {number} arg0
14
70
  */
15
- Cs422: 1, "1": "Cs422",
71
+ set penetration(arg0) {
72
+ wasm.__wbg_set_wasmcontact_penetration(this.__wbg_ptr, arg0);
73
+ }
16
74
  /**
17
- * Not subsampled.
75
+ * @param {number} arg0
18
76
  */
19
- Cs444: 2, "2": "Cs444",
77
+ set point_x(arg0) {
78
+ wasm.__wbg_set_wasmcontact_point_x(this.__wbg_ptr, arg0);
79
+ }
20
80
  /**
21
- * Monochrome.
81
+ * @param {number} arg0
22
82
  */
23
- Cs400: 3, "3": "Cs400",
24
- });
83
+ set point_y(arg0) {
84
+ wasm.__wbg_set_wasmcontact_point_y(this.__wbg_ptr, arg0);
85
+ }
86
+ }
87
+ if (Symbol.dispose) WasmContact.prototype[Symbol.dispose] = WasmContact.prototype.free;
25
88
 
89
+ /**
90
+ * The primary game handle for browser-based games.
91
+ *
92
+ * Owns the ECS world, input state, frame timing, and an optional wgpu
93
+ * rendering backend attached to an HTML canvas element.
94
+ */
26
95
  export class WasmGame {
27
96
  static __wrap(ptr) {
28
97
  ptr = ptr >>> 0;
@@ -41,6 +110,21 @@ export class WasmGame {
41
110
  const ptr = this.__destroy_into_raw();
42
111
  wasm.__wbg_wasmgame_free(ptr, 0);
43
112
  }
113
+ /**
114
+ * @param {number} min_ax
115
+ * @param {number} min_ay
116
+ * @param {number} max_ax
117
+ * @param {number} max_ay
118
+ * @param {number} min_bx
119
+ * @param {number} min_by
120
+ * @param {number} max_bx
121
+ * @param {number} max_by
122
+ * @returns {boolean}
123
+ */
124
+ aabb_overlap(min_ax, min_ay, max_ax, max_ay, min_bx, min_by, max_bx, max_by) {
125
+ const ret = wasm.wasmgame_aabb_overlap(this.__wbg_ptr, min_ax, min_ay, max_ax, max_ay, min_bx, min_by, max_bx, max_by);
126
+ return ret !== 0;
127
+ }
44
128
  /**
45
129
  * @param {bigint} entity_bits
46
130
  * @param {string} name
@@ -57,6 +141,21 @@ export class WasmGame {
57
141
  add_scroll_delta(dx, dy) {
58
142
  wasm.wasmgame_add_scroll_delta(this.__wbg_ptr, dx, dy);
59
143
  }
144
+ /**
145
+ * @param {bigint} entity_bits
146
+ * @param {number} texture_handle
147
+ * @param {number} r
148
+ * @param {number} g
149
+ * @param {number} b
150
+ * @param {number} a
151
+ * @param {boolean} flip_x
152
+ * @param {boolean} flip_y
153
+ * @param {number} anchor_x
154
+ * @param {number} anchor_y
155
+ */
156
+ add_sprite(entity_bits, texture_handle, r, g, b, a, flip_x, flip_y, anchor_x, anchor_y) {
157
+ wasm.wasmgame_add_sprite(this.__wbg_ptr, entity_bits, texture_handle, r, g, b, a, flip_x, flip_y, anchor_x, anchor_y);
158
+ }
60
159
  /**
61
160
  * @param {bigint} entity_bits
62
161
  * @param {number} px
@@ -69,11 +168,69 @@ export class WasmGame {
69
168
  wasm.wasmgame_add_transform2d(this.__wbg_ptr, entity_bits, px, py, rotation, sx, sy);
70
169
  }
71
170
  /**
171
+ * Advances frame timing and prepares the wgpu surface for drawing.
172
+ *
173
+ * Call this at the start of each `requestAnimationFrame` callback.
72
174
  * @param {number} delta_time
73
175
  */
74
176
  begin_frame(delta_time) {
75
177
  wasm.wasmgame_begin_frame(this.__wbg_ptr, delta_time);
76
178
  }
179
+ /**
180
+ * @param {number} x1
181
+ * @param {number} y1
182
+ * @param {number} r1
183
+ * @param {number} x2
184
+ * @param {number} y2
185
+ * @param {number} r2
186
+ * @returns {boolean}
187
+ */
188
+ circle_overlap(x1, y1, r1, x2, y2, r2) {
189
+ const ret = wasm.wasmgame_circle_overlap(this.__wbg_ptr, x1, y1, r1, x2, y2, r2);
190
+ return ret !== 0;
191
+ }
192
+ /**
193
+ * @param {number} center_ax
194
+ * @param {number} center_ay
195
+ * @param {number} half_wa
196
+ * @param {number} half_ha
197
+ * @param {number} center_bx
198
+ * @param {number} center_by
199
+ * @param {number} half_wb
200
+ * @param {number} half_hb
201
+ * @returns {WasmContact | undefined}
202
+ */
203
+ collision_aabb_aabb(center_ax, center_ay, half_wa, half_ha, center_bx, center_by, half_wb, half_hb) {
204
+ const ret = wasm.wasmgame_collision_aabb_aabb(this.__wbg_ptr, center_ax, center_ay, half_wa, half_ha, center_bx, center_by, half_wb, half_hb);
205
+ return ret === 0 ? undefined : WasmContact.__wrap(ret);
206
+ }
207
+ /**
208
+ * @param {number} cx
209
+ * @param {number} cy
210
+ * @param {number} cr
211
+ * @param {number} bx
212
+ * @param {number} by
213
+ * @param {number} bhw
214
+ * @param {number} bhh
215
+ * @returns {WasmContact | undefined}
216
+ */
217
+ collision_circle_aabb(cx, cy, cr, bx, by, bhw, bhh) {
218
+ const ret = wasm.wasmgame_collision_circle_aabb(this.__wbg_ptr, cx, cy, cr, bx, by, bhw, bhh);
219
+ return ret === 0 ? undefined : WasmContact.__wrap(ret);
220
+ }
221
+ /**
222
+ * @param {number} center_ax
223
+ * @param {number} center_ay
224
+ * @param {number} radius_a
225
+ * @param {number} center_bx
226
+ * @param {number} center_by
227
+ * @param {number} radius_b
228
+ * @returns {WasmContact | undefined}
229
+ */
230
+ collision_circle_circle(center_ax, center_ay, radius_a, center_bx, center_by, radius_b) {
231
+ const ret = wasm.wasmgame_collision_circle_circle(this.__wbg_ptr, center_ax, center_ay, radius_a, center_bx, center_by, radius_b);
232
+ return ret === 0 ? undefined : WasmContact.__wrap(ret);
233
+ }
77
234
  /**
78
235
  * Creates a game instance with wgpu rendering attached to a canvas.
79
236
  * @param {HTMLCanvasElement} canvas
@@ -89,6 +246,7 @@ export class WasmGame {
89
246
  return ret;
90
247
  }
91
248
  /**
249
+ * Seconds elapsed since the previous frame.
92
250
  * @returns {number}
93
251
  */
94
252
  get delta_time() {
@@ -103,12 +261,46 @@ export class WasmGame {
103
261
  const ret = wasm.wasmgame_despawn(this.__wbg_ptr, entity_bits);
104
262
  return ret !== 0;
105
263
  }
264
+ /**
265
+ * Despawns multiple entities at once. Returns the number of entities
266
+ * successfully despawned.
267
+ * @param {BigUint64Array} entity_bits
268
+ * @returns {number}
269
+ */
270
+ despawn_batch(entity_bits) {
271
+ const ptr0 = passArray64ToWasm0(entity_bits, wasm.__wbindgen_malloc);
272
+ const len0 = WASM_VECTOR_LEN;
273
+ const ret = wasm.wasmgame_despawn_batch(this.__wbg_ptr, ptr0, len0);
274
+ return ret >>> 0;
275
+ }
106
276
  /**
107
277
  * @param {number} handle
108
278
  */
109
279
  destroy_texture(handle) {
110
280
  wasm.wasmgame_destroy_texture(this.__wbg_ptr, handle);
111
281
  }
282
+ /**
283
+ * @param {number} x1
284
+ * @param {number} y1
285
+ * @param {number} x2
286
+ * @param {number} y2
287
+ * @returns {number}
288
+ */
289
+ distance(x1, y1, x2, y2) {
290
+ const ret = wasm.wasmgame_distance(this.__wbg_ptr, x1, y1, x2, y2);
291
+ return ret;
292
+ }
293
+ /**
294
+ * @param {number} x1
295
+ * @param {number} y1
296
+ * @param {number} x2
297
+ * @param {number} y2
298
+ * @returns {number}
299
+ */
300
+ distance_squared(x1, y1, x2, y2) {
301
+ const ret = wasm.wasmgame_distance_squared(this.__wbg_ptr, x1, y1, x2, y2);
302
+ return ret;
303
+ }
112
304
  /**
113
305
  * @param {number} x
114
306
  * @param {number} y
@@ -137,6 +329,32 @@ export class WasmGame {
137
329
  draw_sprite(texture, x, y, w, h, rotation, r, g, b, a) {
138
330
  wasm.wasmgame_draw_sprite(this.__wbg_ptr, texture, x, y, w, h, rotation, r, g, b, a);
139
331
  }
332
+ /**
333
+ * @param {number} texture
334
+ * @param {number} x
335
+ * @param {number} y
336
+ * @param {number} w
337
+ * @param {number} h
338
+ * @param {number} rotation
339
+ * @param {number} src_x
340
+ * @param {number} src_y
341
+ * @param {number} src_w
342
+ * @param {number} src_h
343
+ * @param {number} r
344
+ * @param {number} g
345
+ * @param {number} b
346
+ * @param {number} a
347
+ * @returns {boolean}
348
+ */
349
+ draw_sprite_rect(texture, x, y, w, h, rotation, src_x, src_y, src_w, src_h, r, g, b, a) {
350
+ const ret = wasm.wasmgame_draw_sprite_rect(this.__wbg_ptr, texture, x, y, w, h, rotation, src_x, src_y, src_w, src_h, r, g, b, a);
351
+ return ret !== 0;
352
+ }
353
+ /**
354
+ * Flushes queued draw calls and presents the frame to the canvas.
355
+ *
356
+ * Call this at the end of each `requestAnimationFrame` callback.
357
+ */
140
358
  end_frame() {
141
359
  wasm.wasmgame_end_frame(this.__wbg_ptr);
142
360
  }
@@ -148,6 +366,7 @@ export class WasmGame {
148
366
  return ret >>> 0;
149
367
  }
150
368
  /**
369
+ * Approximate frames per second based on the most recent delta.
151
370
  * @returns {number}
152
371
  */
153
372
  get fps() {
@@ -155,6 +374,7 @@ export class WasmGame {
155
374
  return ret;
156
375
  }
157
376
  /**
377
+ * Number of frames rendered since the game started.
158
378
  * @returns {bigint}
159
379
  */
160
380
  get frame_count() {
@@ -174,6 +394,23 @@ export class WasmGame {
174
394
  }
175
395
  return v1;
176
396
  }
397
+ /**
398
+ * Returns render statistics for the current frame, or `None` if
399
+ * rendering is not active.
400
+ * @returns {WasmRenderStats | undefined}
401
+ */
402
+ get_render_stats() {
403
+ const ret = wasm.wasmgame_get_render_stats(this.__wbg_ptr);
404
+ return ret === 0 ? undefined : WasmRenderStats.__wrap(ret);
405
+ }
406
+ /**
407
+ * @param {bigint} entity_bits
408
+ * @returns {WasmSprite | undefined}
409
+ */
410
+ get_sprite(entity_bits) {
411
+ const ret = wasm.wasmgame_get_sprite(this.__wbg_ptr, entity_bits);
412
+ return ret === 0 ? undefined : WasmSprite.__wrap(ret);
413
+ }
177
414
  /**
178
415
  * @param {bigint} entity_bits
179
416
  * @returns {WasmTransform2D | undefined}
@@ -191,13 +428,22 @@ export class WasmGame {
191
428
  return ret !== 0;
192
429
  }
193
430
  /**
194
- * Whether wgpu rendering is active.
431
+ * Returns `true` when wgpu rendering is active (canvas was provided at
432
+ * construction time).
195
433
  * @returns {boolean}
196
434
  */
197
435
  has_renderer() {
198
436
  const ret = wasm.wasmgame_has_renderer(this.__wbg_ptr);
199
437
  return ret !== 0;
200
438
  }
439
+ /**
440
+ * @param {bigint} entity_bits
441
+ * @returns {boolean}
442
+ */
443
+ has_sprite(entity_bits) {
444
+ const ret = wasm.wasmgame_has_sprite(this.__wbg_ptr, entity_bits);
445
+ return ret !== 0;
446
+ }
201
447
  /**
202
448
  * @param {bigint} entity_bits
203
449
  * @returns {boolean}
@@ -206,6 +452,41 @@ export class WasmGame {
206
452
  const ret = wasm.wasmgame_has_transform2d(this.__wbg_ptr, entity_bits);
207
453
  return ret !== 0;
208
454
  }
455
+ /**
456
+ * Returns `true` if any key mapped to the given action was just pressed
457
+ * this frame (not held from previous frame).
458
+ * @param {string} action
459
+ * @returns {boolean}
460
+ */
461
+ is_action_just_pressed(action) {
462
+ const ptr0 = passStringToWasm0(action, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
463
+ const len0 = WASM_VECTOR_LEN;
464
+ const ret = wasm.wasmgame_is_action_just_pressed(this.__wbg_ptr, ptr0, len0);
465
+ return ret !== 0;
466
+ }
467
+ /**
468
+ * Returns `true` if any key mapped to the given action was just released
469
+ * this frame (held previous frame but not current).
470
+ * @param {string} action
471
+ * @returns {boolean}
472
+ */
473
+ is_action_just_released(action) {
474
+ const ptr0 = passStringToWasm0(action, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
475
+ const len0 = WASM_VECTOR_LEN;
476
+ const ret = wasm.wasmgame_is_action_just_released(this.__wbg_ptr, ptr0, len0);
477
+ return ret !== 0;
478
+ }
479
+ /**
480
+ * Returns `true` if any key mapped to the given action is currently held.
481
+ * @param {string} action
482
+ * @returns {boolean}
483
+ */
484
+ is_action_pressed(action) {
485
+ const ptr0 = passStringToWasm0(action, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
486
+ const len0 = WASM_VECTOR_LEN;
487
+ const ret = wasm.wasmgame_is_action_pressed(this.__wbg_ptr, ptr0, len0);
488
+ return ret !== 0;
489
+ }
209
490
  /**
210
491
  * @param {bigint} entity_bits
211
492
  * @returns {boolean}
@@ -246,6 +527,14 @@ export class WasmGame {
246
527
  const ret = wasm.wasmgame_is_mouse_button_just_pressed(this.__wbg_ptr, button);
247
528
  return ret !== 0;
248
529
  }
530
+ /**
531
+ * @param {number} button
532
+ * @returns {boolean}
533
+ */
534
+ is_mouse_button_just_released(button) {
535
+ const ret = wasm.wasmgame_is_mouse_button_just_released(this.__wbg_ptr, button);
536
+ return ret !== 0;
537
+ }
249
538
  /**
250
539
  * @param {number} button
251
540
  * @returns {boolean}
@@ -255,16 +544,17 @@ export class WasmGame {
255
544
  return ret !== 0;
256
545
  }
257
546
  /**
258
- * Loads a texture from a URL. Returns the texture handle (1-based;
259
- * 0 is reserved for the white fallback texture used by draw_quad).
260
- * @param {string} url
261
- * @returns {Promise<number>}
547
+ * Maps an action name to a key code. Multiple keys can be mapped
548
+ * to the same action. Returns `true` on success.
549
+ * @param {string} action
550
+ * @param {number} key
551
+ * @returns {boolean}
262
552
  */
263
- load_texture(url) {
264
- const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
553
+ map_action_key(action, key) {
554
+ const ptr0 = passStringToWasm0(action, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
265
555
  const len0 = WASM_VECTOR_LEN;
266
- const ret = wasm.wasmgame_load_texture(this.__wbg_ptr, ptr0, len0);
267
- return ret;
556
+ const ret = wasm.wasmgame_map_action_key(this.__wbg_ptr, ptr0, len0, key);
557
+ return ret !== 0;
268
558
  }
269
559
  /**
270
560
  * @returns {number}
@@ -294,6 +584,31 @@ export class WasmGame {
294
584
  WasmGameFinalization.register(this, this.__wbg_ptr, this);
295
585
  return this;
296
586
  }
587
+ /**
588
+ * @param {number} px
589
+ * @param {number} py
590
+ * @param {number} cx
591
+ * @param {number} cy
592
+ * @param {number} r
593
+ * @returns {boolean}
594
+ */
595
+ point_in_circle(px, py, cx, cy, r) {
596
+ const ret = wasm.wasmgame_point_in_circle(this.__wbg_ptr, px, py, cx, cy, r);
597
+ return ret !== 0;
598
+ }
599
+ /**
600
+ * @param {number} px
601
+ * @param {number} py
602
+ * @param {number} rx
603
+ * @param {number} ry
604
+ * @param {number} rw
605
+ * @param {number} rh
606
+ * @returns {boolean}
607
+ */
608
+ point_in_rect(px, py, rx, ry, rw, rh) {
609
+ const ret = wasm.wasmgame_point_in_rect(this.__wbg_ptr, px, py, rx, ry, rw, rh);
610
+ return ret !== 0;
611
+ }
297
612
  /**
298
613
  * @param {number} key_code
299
614
  */
@@ -306,6 +621,25 @@ export class WasmGame {
306
621
  press_mouse_button(button) {
307
622
  wasm.wasmgame_press_mouse_button(this.__wbg_ptr, button);
308
623
  }
624
+ /**
625
+ * Registers a texture from raw image bytes (PNG, JPG, etc.).
626
+ *
627
+ * The browser-side SDK fetches the image data asynchronously, then
628
+ * passes the raw bytes here for synchronous decode + GPU upload.
629
+ * Returns the texture handle (1-based; 0 is reserved for the white
630
+ * fallback texture used by `draw_quad`).
631
+ * @param {Uint8Array} data
632
+ * @returns {number}
633
+ */
634
+ register_texture_from_bytes(data) {
635
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
636
+ const len0 = WASM_VECTOR_LEN;
637
+ const ret = wasm.wasmgame_register_texture_from_bytes(this.__wbg_ptr, ptr0, len0);
638
+ if (ret[2]) {
639
+ throw takeFromExternrefTable0(ret[1]);
640
+ }
641
+ return ret[0] >>> 0;
642
+ }
309
643
  /**
310
644
  * @param {number} key_code
311
645
  */
@@ -326,6 +660,14 @@ export class WasmGame {
326
660
  const ret = wasm.wasmgame_remove_name(this.__wbg_ptr, entity_bits);
327
661
  return ret !== 0;
328
662
  }
663
+ /**
664
+ * @param {bigint} entity_bits
665
+ * @returns {boolean}
666
+ */
667
+ remove_sprite(entity_bits) {
668
+ const ret = wasm.wasmgame_remove_sprite(this.__wbg_ptr, entity_bits);
669
+ return ret !== 0;
670
+ }
329
671
  /**
330
672
  * @param {bigint} entity_bits
331
673
  * @returns {boolean}
@@ -357,8 +699,9 @@ export class WasmGame {
357
699
  wasm.wasmgame_set_canvas_size(this.__wbg_ptr, width, height);
358
700
  }
359
701
  /**
360
- * Sets the background clear color (called before begin_frame or via
361
- * the TypeScript SDK's beginFrame parameters).
702
+ * Sets the background clear color.
703
+ *
704
+ * Takes effect on the next `begin_frame` / `end_frame` pair.
362
705
  * @param {number} r
363
706
  * @param {number} g
364
707
  * @param {number} b
@@ -374,6 +717,21 @@ export class WasmGame {
374
717
  set_mouse_position(x, y) {
375
718
  wasm.wasmgame_set_mouse_position(this.__wbg_ptr, x, y);
376
719
  }
720
+ /**
721
+ * @param {bigint} entity_bits
722
+ * @param {number} texture_handle
723
+ * @param {number} r
724
+ * @param {number} g
725
+ * @param {number} b
726
+ * @param {number} a
727
+ * @param {boolean} flip_x
728
+ * @param {boolean} flip_y
729
+ * @param {number} anchor_x
730
+ * @param {number} anchor_y
731
+ */
732
+ set_sprite(entity_bits, texture_handle, r, g, b, a, flip_x, flip_y, anchor_x, anchor_y) {
733
+ wasm.wasmgame_set_sprite(this.__wbg_ptr, entity_bits, texture_handle, r, g, b, a, flip_x, flip_y, anchor_x, anchor_y);
734
+ }
377
735
  /**
378
736
  * @param {bigint} entity_bits
379
737
  * @param {number} px
@@ -403,6 +761,7 @@ export class WasmGame {
403
761
  return BigInt.asUintN(64, ret);
404
762
  }
405
763
  /**
764
+ * The title string passed at construction time.
406
765
  * @returns {string}
407
766
  */
408
767
  get title() {
@@ -418,6 +777,7 @@ export class WasmGame {
418
777
  }
419
778
  }
420
779
  /**
780
+ * Total seconds elapsed since the game started.
421
781
  * @returns {number}
422
782
  */
423
783
  get total_time() {
@@ -425,6 +785,7 @@ export class WasmGame {
425
785
  return ret;
426
786
  }
427
787
  /**
788
+ * Logical canvas height in pixels.
428
789
  * @returns {number}
429
790
  */
430
791
  get window_height() {
@@ -432,6 +793,7 @@ export class WasmGame {
432
793
  return ret >>> 0;
433
794
  }
434
795
  /**
796
+ * Logical canvas width in pixels.
435
797
  * @returns {number}
436
798
  */
437
799
  get window_width() {
@@ -441,6 +803,215 @@ export class WasmGame {
441
803
  }
442
804
  if (Symbol.dispose) WasmGame.prototype[Symbol.dispose] = WasmGame.prototype.free;
443
805
 
806
+ /**
807
+ * Per-frame rendering statistics exposed to JavaScript.
808
+ */
809
+ export class WasmRenderStats {
810
+ static __wrap(ptr) {
811
+ ptr = ptr >>> 0;
812
+ const obj = Object.create(WasmRenderStats.prototype);
813
+ obj.__wbg_ptr = ptr;
814
+ WasmRenderStatsFinalization.register(obj, obj.__wbg_ptr, obj);
815
+ return obj;
816
+ }
817
+ __destroy_into_raw() {
818
+ const ptr = this.__wbg_ptr;
819
+ this.__wbg_ptr = 0;
820
+ WasmRenderStatsFinalization.unregister(this);
821
+ return ptr;
822
+ }
823
+ free() {
824
+ const ptr = this.__destroy_into_raw();
825
+ wasm.__wbg_wasmrenderstats_free(ptr, 0);
826
+ }
827
+ /**
828
+ * @returns {number}
829
+ */
830
+ get draw_calls() {
831
+ const ret = wasm.__wbg_get_wasmrenderstats_draw_calls(this.__wbg_ptr);
832
+ return ret >>> 0;
833
+ }
834
+ /**
835
+ * @returns {number}
836
+ */
837
+ get texture_binds() {
838
+ const ret = wasm.__wbg_get_wasmrenderstats_texture_binds(this.__wbg_ptr);
839
+ return ret >>> 0;
840
+ }
841
+ /**
842
+ * @returns {number}
843
+ */
844
+ get triangles() {
845
+ const ret = wasm.__wbg_get_wasmrenderstats_triangles(this.__wbg_ptr);
846
+ return ret >>> 0;
847
+ }
848
+ /**
849
+ * @param {number} arg0
850
+ */
851
+ set draw_calls(arg0) {
852
+ wasm.__wbg_set_wasmrenderstats_draw_calls(this.__wbg_ptr, arg0);
853
+ }
854
+ /**
855
+ * @param {number} arg0
856
+ */
857
+ set texture_binds(arg0) {
858
+ wasm.__wbg_set_wasmrenderstats_texture_binds(this.__wbg_ptr, arg0);
859
+ }
860
+ /**
861
+ * @param {number} arg0
862
+ */
863
+ set triangles(arg0) {
864
+ wasm.__wbg_set_wasmrenderstats_triangles(this.__wbg_ptr, arg0);
865
+ }
866
+ }
867
+ if (Symbol.dispose) WasmRenderStats.prototype[Symbol.dispose] = WasmRenderStats.prototype.free;
868
+
869
+ /**
870
+ * A plain-data snapshot of a `Sprite` component, safe to pass across
871
+ * the wasm-bindgen boundary.
872
+ */
873
+ export class WasmSprite {
874
+ static __wrap(ptr) {
875
+ ptr = ptr >>> 0;
876
+ const obj = Object.create(WasmSprite.prototype);
877
+ obj.__wbg_ptr = ptr;
878
+ WasmSpriteFinalization.register(obj, obj.__wbg_ptr, obj);
879
+ return obj;
880
+ }
881
+ __destroy_into_raw() {
882
+ const ptr = this.__wbg_ptr;
883
+ this.__wbg_ptr = 0;
884
+ WasmSpriteFinalization.unregister(this);
885
+ return ptr;
886
+ }
887
+ free() {
888
+ const ptr = this.__destroy_into_raw();
889
+ wasm.__wbg_wasmsprite_free(ptr, 0);
890
+ }
891
+ /**
892
+ * @returns {number}
893
+ */
894
+ get a() {
895
+ const ret = wasm.__wbg_get_wasmsprite_a(this.__wbg_ptr);
896
+ return ret;
897
+ }
898
+ /**
899
+ * @returns {number}
900
+ */
901
+ get anchor_x() {
902
+ const ret = wasm.__wbg_get_wasmsprite_anchor_x(this.__wbg_ptr);
903
+ return ret;
904
+ }
905
+ /**
906
+ * @returns {number}
907
+ */
908
+ get anchor_y() {
909
+ const ret = wasm.__wbg_get_wasmsprite_anchor_y(this.__wbg_ptr);
910
+ return ret;
911
+ }
912
+ /**
913
+ * @returns {number}
914
+ */
915
+ get b() {
916
+ const ret = wasm.__wbg_get_wasmsprite_b(this.__wbg_ptr);
917
+ return ret;
918
+ }
919
+ /**
920
+ * @returns {boolean}
921
+ */
922
+ get flip_x() {
923
+ const ret = wasm.__wbg_get_wasmsprite_flip_x(this.__wbg_ptr);
924
+ return ret !== 0;
925
+ }
926
+ /**
927
+ * @returns {boolean}
928
+ */
929
+ get flip_y() {
930
+ const ret = wasm.__wbg_get_wasmsprite_flip_y(this.__wbg_ptr);
931
+ return ret !== 0;
932
+ }
933
+ /**
934
+ * @returns {number}
935
+ */
936
+ get g() {
937
+ const ret = wasm.__wbg_get_wasmsprite_g(this.__wbg_ptr);
938
+ return ret;
939
+ }
940
+ /**
941
+ * @returns {number}
942
+ */
943
+ get r() {
944
+ const ret = wasm.__wbg_get_wasmsprite_r(this.__wbg_ptr);
945
+ return ret;
946
+ }
947
+ /**
948
+ * @returns {number}
949
+ */
950
+ get texture_handle() {
951
+ const ret = wasm.__wbg_get_wasmsprite_texture_handle(this.__wbg_ptr);
952
+ return ret >>> 0;
953
+ }
954
+ /**
955
+ * @param {number} arg0
956
+ */
957
+ set a(arg0) {
958
+ wasm.__wbg_set_wasmsprite_a(this.__wbg_ptr, arg0);
959
+ }
960
+ /**
961
+ * @param {number} arg0
962
+ */
963
+ set anchor_x(arg0) {
964
+ wasm.__wbg_set_wasmsprite_anchor_x(this.__wbg_ptr, arg0);
965
+ }
966
+ /**
967
+ * @param {number} arg0
968
+ */
969
+ set anchor_y(arg0) {
970
+ wasm.__wbg_set_wasmsprite_anchor_y(this.__wbg_ptr, arg0);
971
+ }
972
+ /**
973
+ * @param {number} arg0
974
+ */
975
+ set b(arg0) {
976
+ wasm.__wbg_set_wasmsprite_b(this.__wbg_ptr, arg0);
977
+ }
978
+ /**
979
+ * @param {boolean} arg0
980
+ */
981
+ set flip_x(arg0) {
982
+ wasm.__wbg_set_wasmsprite_flip_x(this.__wbg_ptr, arg0);
983
+ }
984
+ /**
985
+ * @param {boolean} arg0
986
+ */
987
+ set flip_y(arg0) {
988
+ wasm.__wbg_set_wasmsprite_flip_y(this.__wbg_ptr, arg0);
989
+ }
990
+ /**
991
+ * @param {number} arg0
992
+ */
993
+ set g(arg0) {
994
+ wasm.__wbg_set_wasmsprite_g(this.__wbg_ptr, arg0);
995
+ }
996
+ /**
997
+ * @param {number} arg0
998
+ */
999
+ set r(arg0) {
1000
+ wasm.__wbg_set_wasmsprite_r(this.__wbg_ptr, arg0);
1001
+ }
1002
+ /**
1003
+ * @param {number} arg0
1004
+ */
1005
+ set texture_handle(arg0) {
1006
+ wasm.__wbg_set_wasmsprite_texture_handle(this.__wbg_ptr, arg0);
1007
+ }
1008
+ }
1009
+ if (Symbol.dispose) WasmSprite.prototype[Symbol.dispose] = WasmSprite.prototype.free;
1010
+
1011
+ /**
1012
+ * A plain-data snapshot of a `Transform2D` component, safe to pass across
1013
+ * the wasm-bindgen boundary.
1014
+ */
444
1015
  export class WasmTransform2D {
445
1016
  static __wrap(ptr) {
446
1017
  ptr = ptr >>> 0;
@@ -563,10 +1134,6 @@ function __wbg_get_imports() {
563
1134
  __wbg__wbg_cb_unref_6b5b6b8576d35cb1: function(arg0) {
564
1135
  arg0._wbg_cb_unref();
565
1136
  },
566
- __wbg_arrayBuffer_eb8e9ca620af2a19: function() { return handleError(function (arg0) {
567
- const ret = arg0.arrayBuffer();
568
- return ret;
569
- }, arguments); },
570
1137
  __wbg_beginRenderPass_b6be55dca13d3752: function() { return handleError(function (arg0, arg1) {
571
1138
  const ret = arg0.beginRenderPass(arg1);
572
1139
  return ret;
@@ -635,10 +1202,6 @@ function __wbg_get_imports() {
635
1202
  __wbg_error_8d9a8e04cd1d3588: function(arg0) {
636
1203
  console.error(arg0);
637
1204
  },
638
- __wbg_fetch_e261f234f8b50660: function(arg0, arg1, arg2) {
639
- const ret = arg0.fetch(getStringFromWasm0(arg1, arg2));
640
- return ret;
641
- },
642
1205
  __wbg_finish_1f441b2d9fcf60d0: function(arg0, arg1) {
643
1206
  const ret = arg0.finish(arg1);
644
1207
  return ret;
@@ -695,16 +1258,6 @@ function __wbg_get_imports() {
695
1258
  const ret = result;
696
1259
  return ret;
697
1260
  },
698
- __wbg_instanceof_Response_9b4d9fd451e051b1: function(arg0) {
699
- let result;
700
- try {
701
- result = arg0 instanceof Response;
702
- } catch (_) {
703
- result = false;
704
- }
705
- const ret = result;
706
- return ret;
707
- },
708
1261
  __wbg_instanceof_Window_23e677d2c6843922: function(arg0) {
709
1262
  let result;
710
1263
  try {
@@ -738,10 +1291,6 @@ function __wbg_get_imports() {
738
1291
  const ret = arg0.navigator;
739
1292
  return ret;
740
1293
  },
741
- __wbg_new_5f486cdf45a04d78: function(arg0) {
742
- const ret = new Uint8Array(arg0);
743
- return ret;
744
- },
745
1294
  __wbg_new_ab79df5bd7c26067: function() {
746
1295
  const ret = new Object();
747
1296
  return ret;
@@ -776,10 +1325,6 @@ function __wbg_get_imports() {
776
1325
  const ret = new Uint8Array(arg0, arg1 >>> 0, arg2 >>> 0);
777
1326
  return ret;
778
1327
  },
779
- __wbg_ok_7ec8b94facac7704: function(arg0) {
780
- const ret = arg0.ok;
781
- return ret;
782
- },
783
1328
  __wbg_onSubmittedWorkDone_a33e32762de21b3d: function(arg0) {
784
1329
  const ret = arg0.onSubmittedWorkDone();
785
1330
  return ret;
@@ -1348,10 +1893,6 @@ function __wbg_get_imports() {
1348
1893
  const ret = typeof window === 'undefined' ? null : window;
1349
1894
  return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1350
1895
  },
1351
- __wbg_status_318629ab93a22955: function(arg0) {
1352
- const ret = arg0.status;
1353
- return ret;
1354
- },
1355
1896
  __wbg_submit_19b0e21319bc36d7: function(arg0, arg1) {
1356
1897
  arg0.submit(arg1);
1357
1898
  },
@@ -1381,12 +1922,12 @@ function __wbg_get_imports() {
1381
1922
  arg0.writeTexture(arg1, arg2, arg3, arg4);
1382
1923
  }, arguments); },
1383
1924
  __wbindgen_cast_0000000000000001: function(arg0, arg1) {
1384
- // Cast intrinsic for `Closure(Closure { dtor_idx: 72, function: Function { arguments: [Externref], shim_idx: 73, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1925
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 61, function: Function { arguments: [Externref], shim_idx: 62, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1385
1926
  const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h34b32f47e9536ad7, wasm_bindgen__convert__closures_____invoke__h8b43903f8a91b24f);
1386
1927
  return ret;
1387
1928
  },
1388
1929
  __wbindgen_cast_0000000000000002: function(arg0, arg1) {
1389
- // Cast intrinsic for `Closure(Closure { dtor_idx: 777, function: Function { arguments: [Externref], shim_idx: 778, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1930
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 766, function: Function { arguments: [Externref], shim_idx: 767, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1390
1931
  const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__hb7ee5c5d3fd608d4, wasm_bindgen__convert__closures_____invoke__h6c9ef6970fdda1f4);
1391
1932
  return ret;
1392
1933
  },
@@ -1510,9 +2051,18 @@ const __wbindgen_enum_GpuVertexFormat = ["uint8", "uint8x2", "uint8x4", "sint8",
1510
2051
 
1511
2052
 
1512
2053
  const __wbindgen_enum_GpuVertexStepMode = ["vertex", "instance"];
2054
+ const WasmContactFinalization = (typeof FinalizationRegistry === 'undefined')
2055
+ ? { register: () => {}, unregister: () => {} }
2056
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmcontact_free(ptr >>> 0, 1));
1513
2057
  const WasmGameFinalization = (typeof FinalizationRegistry === 'undefined')
1514
2058
  ? { register: () => {}, unregister: () => {} }
1515
2059
  : new FinalizationRegistry(ptr => wasm.__wbg_wasmgame_free(ptr >>> 0, 1));
2060
+ const WasmRenderStatsFinalization = (typeof FinalizationRegistry === 'undefined')
2061
+ ? { register: () => {}, unregister: () => {} }
2062
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmrenderstats_free(ptr >>> 0, 1));
2063
+ const WasmSpriteFinalization = (typeof FinalizationRegistry === 'undefined')
2064
+ ? { register: () => {}, unregister: () => {} }
2065
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmsprite_free(ptr >>> 0, 1));
1516
2066
  const WasmTransform2DFinalization = (typeof FinalizationRegistry === 'undefined')
1517
2067
  ? { register: () => {}, unregister: () => {} }
1518
2068
  : new FinalizationRegistry(ptr => wasm.__wbg_wasmtransform2d_free(ptr >>> 0, 1));
@@ -1685,6 +2235,20 @@ function makeMutClosure(arg0, arg1, dtor, f) {
1685
2235
  return real;
1686
2236
  }
1687
2237
 
2238
+ function passArray64ToWasm0(arg, malloc) {
2239
+ const ptr = malloc(arg.length * 8, 8) >>> 0;
2240
+ getBigUint64ArrayMemory0().set(arg, ptr / 8);
2241
+ WASM_VECTOR_LEN = arg.length;
2242
+ return ptr;
2243
+ }
2244
+
2245
+ function passArray8ToWasm0(arg, malloc) {
2246
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
2247
+ getUint8ArrayMemory0().set(arg, ptr / 1);
2248
+ WASM_VECTOR_LEN = arg.length;
2249
+ return ptr;
2250
+ }
2251
+
1688
2252
  function passStringToWasm0(arg, malloc, realloc) {
1689
2253
  if (realloc === undefined) {
1690
2254
  const buf = cachedTextEncoder.encode(arg);