q5play 4.0.6 → 4.0.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "q5play",
3
- "version": "4.0.6",
3
+ "version": "4.0.7",
4
4
  "author": "quinton-ashley",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "description": "A web-based game engine that uses q5.js WebGPU for graphics and Box2D v3 WASM for physics.",
package/q5play.d.ts CHANGED
@@ -70,6 +70,14 @@ declare global {
70
70
  * @default false
71
71
  */
72
72
  renderStats: boolean;
73
+ /**
74
+ * Runs automatically before each draw function call.
75
+ */
76
+ update(): void;
77
+ /**
78
+ * Runs automatically after each draw function call.
79
+ */
80
+ postDraw(): void;
73
81
  }
74
82
  const q5play: Q5Play;
75
83
 
package/q5play.js CHANGED
@@ -248,6 +248,9 @@ async function q5playPreSetup(q) {
248
248
  this.os = {};
249
249
  this.context = 'web';
250
250
 
251
+ this.update = () => q5playUpdate.call($, q);
252
+ this.postdraw = () => q5playPostDraw.call($, q);
253
+
251
254
  if (window.matchMedia) {
252
255
  this.hasMouse = window.matchMedia('(any-hover: none)').matches ? false : true;
253
256
  } else this.hasMouse = true;
@@ -7812,7 +7815,7 @@ async function q5playPreSetup(q) {
7812
7815
  debugYellow = $.color(colorMax, colorMax, 0, colorMax * 0.9),
7813
7816
  debugYellowFill = $.color(colorMax, colorMax, 0, colorMax * 0.1);
7814
7817
 
7815
- if ($._c2d) {
7818
+ if ($.canvas.c2d) {
7816
7819
  // polyfill for q5 WebGPU high efficiency functions
7817
7820
  $._getFillIdx = () => $._fill;
7818
7821
  $._setFillIdx = (v) => ($._fill = v);
@@ -8026,7 +8029,7 @@ function q5playPostSetup() {
8026
8029
  }
8027
8030
 
8028
8031
  // called before each draw function call
8029
- function q5playPreDraw() {
8032
+ function q5playUpdate() {
8030
8033
  const $ = this;
8031
8034
 
8032
8035
  if (!$._q5) {
@@ -8382,6 +8385,6 @@ q5playClassLangs.Group += q5playClassLangs.Sprite;
8382
8385
 
8383
8386
  Q5.addHook('presetup', q5playPreSetup);
8384
8387
  Q5.addHook('postsetup', q5playPostSetup);
8385
- Q5.addHook('predraw', q5playPreDraw);
8388
+ Q5.addHook('predraw', q5playUpdate);
8386
8389
  Q5.addHook('postdraw', q5playPostDraw);
8387
8390
  Q5.addHook('remove', q5playRemove);