1681-engine 0.6.3 → 0.6.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.
- package/CHANGELOG.md +22 -0
- package/dist/core/Group.js +12 -8
- package/dist/core/TextureRegistry.js +45 -33
- package/dist/pixel/lifeArt.js +63 -48
- package/dist/types/core/Group.d.ts +6 -2
- package/dist/types/core/Group.d.ts.map +1 -1
- package/dist/types/core/TextureRegistry.d.ts +17 -3
- package/dist/types/core/TextureRegistry.d.ts.map +1 -1
- package/dist/types/pixel/lifeArt.d.ts +8 -0
- package/dist/types/pixel/lifeArt.d.ts.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,28 @@
|
|
|
3
3
|
All notable changes to this package are written here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
4
4
|
and versions follow [Semantic Versioning](https://semver.org/); before 1.0 a minor version may break the API.
|
|
5
5
|
|
|
6
|
+
## 0.6.6
|
|
7
|
+
|
|
8
|
+
### Added
|
|
9
|
+
|
|
10
|
+
- `TextureRegistry.addView(key, page, x, y, w, h)`: a key that is one rect of another texture, on that texture's own
|
|
11
|
+
source (`CanvasTexture`'s `view`), so pieces swapped every few frames batch together.
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
- `paintLifeArt` lays every piece of the ambient life (leaves, seeds, embers, motes, ash, butterflies, birds,
|
|
16
|
+
fireflies, smoke) on one page and registers each key as a view of it (`packShelves`). A canvas each made every flap
|
|
17
|
+
of a butterfly or puff of smoke a texture of another source, and Pixi rebuilt the world's draw instructions at each.
|
|
18
|
+
The keys and `LifeArt` are unchanged.
|
|
19
|
+
|
|
20
|
+
## 0.6.5
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
|
|
24
|
+
- `Group.moveAbove` / `moveBelow` do nothing when the child is already directly above / below the other. Taking it out
|
|
25
|
+
and putting it back marked the render group's structure changed, so Pixi rebuilt its draw instructions that frame:
|
|
26
|
+
a game ordering a held weapon against its body every frame rebuilt them every frame.
|
|
27
|
+
|
|
6
28
|
## 0.6.3
|
|
7
29
|
|
|
8
30
|
### Changed
|
package/dist/core/Group.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Container as
|
|
2
|
-
import { GameObject as
|
|
3
|
-
class
|
|
1
|
+
import { Container as i } from "pixi.js";
|
|
2
|
+
import { GameObject as r } from "./gameObject.js";
|
|
3
|
+
class d extends r(i) {
|
|
4
4
|
get list() {
|
|
5
5
|
return this.children;
|
|
6
6
|
}
|
|
@@ -14,15 +14,19 @@ class a extends i(r) {
|
|
|
14
14
|
remove(t, e = !1) {
|
|
15
15
|
return t.parent === this && this.removeChild(t), e && t.destroy({ children: !0, context: !0 }), this;
|
|
16
16
|
}
|
|
17
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* Puts `child` directly below `other` in the draw order. Already there, it does nothing: taking a child out and
|
|
19
|
+
* putting it back marks the render group's structure changed, and Pixi rebuilds its draw instructions for that
|
|
20
|
+
* frame — a held weapon ordered against its body every frame did it every frame.
|
|
21
|
+
*/
|
|
18
22
|
moveBelow(t, e) {
|
|
19
|
-
return t.parent !== this || e.parent !== this || t === e ? this : (this.removeChild(t), this.addChildAt(t, this.getChildIndex(e)), this);
|
|
23
|
+
return t.parent !== this || e.parent !== this || t === e ? this : this.getChildIndex(t) === this.getChildIndex(e) - 1 ? this : (this.removeChild(t), this.addChildAt(t, this.getChildIndex(e)), this);
|
|
20
24
|
}
|
|
21
|
-
/** Puts `child` directly above `other` in the draw order. */
|
|
25
|
+
/** Puts `child` directly above `other` in the draw order; already there, it does nothing (see `moveBelow`). */
|
|
22
26
|
moveAbove(t, e) {
|
|
23
|
-
return t.parent !== this || e.parent !== this || t === e ? this : (this.removeChild(t), this.addChildAt(t, this.getChildIndex(e) + 1), this);
|
|
27
|
+
return t.parent !== this || e.parent !== this || t === e ? this : this.getChildIndex(t) === this.getChildIndex(e) + 1 ? this : (this.removeChild(t), this.addChildAt(t, this.getChildIndex(e) + 1), this);
|
|
24
28
|
}
|
|
25
29
|
}
|
|
26
30
|
export {
|
|
27
|
-
|
|
31
|
+
d as Group
|
|
28
32
|
};
|
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
import { CanvasSource as
|
|
2
|
-
class
|
|
3
|
-
constructor(t, s) {
|
|
4
|
-
this.key = t, this.canvas = s, this.source = new
|
|
1
|
+
import { CanvasSource as m, Texture as c, Rectangle as u } from "pixi.js";
|
|
2
|
+
class f {
|
|
3
|
+
constructor(t, s, e) {
|
|
4
|
+
this.key = t, this.canvas = s, this.owned = !e, this.source = e?.source ?? new m({ resource: s, scaleMode: "nearest" }), this.whole = e ? new c({ source: this.source, frame: e.frame }) : new c({ source: this.source });
|
|
5
5
|
}
|
|
6
6
|
key;
|
|
7
7
|
canvas;
|
|
8
8
|
frames = /* @__PURE__ */ new Map();
|
|
9
9
|
source;
|
|
10
10
|
whole;
|
|
11
|
+
owned;
|
|
11
12
|
get width() {
|
|
12
|
-
return this.canvas.width;
|
|
13
|
+
return this.owned ? this.canvas.width : this.whole.frame.width;
|
|
13
14
|
}
|
|
14
15
|
get height() {
|
|
15
|
-
return this.canvas.height;
|
|
16
|
+
return this.owned ? this.canvas.height : this.whole.frame.height;
|
|
16
17
|
}
|
|
17
18
|
get context() {
|
|
18
19
|
return this.canvas.getContext("2d");
|
|
19
20
|
}
|
|
20
21
|
/** Adds a frame cut from the canvas (`_source` kept for the old call shape). */
|
|
21
|
-
add(t, s, e, a,
|
|
22
|
-
this.frames.get(t)?.destroy(), this.frames.set(t, new
|
|
22
|
+
add(t, s, e, a, i, h) {
|
|
23
|
+
this.frames.get(t)?.destroy(), this.frames.set(t, new c({ source: this.source, frame: new u(e, a, i, h) }));
|
|
23
24
|
}
|
|
24
25
|
/**
|
|
25
26
|
* Adds a packed frame cut from `page` (this texture's canvas by default): trimmed frames keep their untrimmed size
|
|
@@ -27,7 +28,7 @@ class v {
|
|
|
27
28
|
*/
|
|
28
29
|
addPacked(t, s = this) {
|
|
29
30
|
this.frames.get(t.name)?.destroy();
|
|
30
|
-
const e = new
|
|
31
|
+
const e = new c({
|
|
31
32
|
source: s.source,
|
|
32
33
|
frame: new u(t.x, t.y, t.w, t.h),
|
|
33
34
|
orig: new u(0, 0, t.sourceW, t.sourceH),
|
|
@@ -43,17 +44,17 @@ class v {
|
|
|
43
44
|
*/
|
|
44
45
|
adopt(t, s) {
|
|
45
46
|
const e = s.frames.get(t);
|
|
46
|
-
e && (this.frames.get(t)?.destroy(), this.frames.set(t, new
|
|
47
|
+
e && (this.frames.get(t)?.destroy(), this.frames.set(t, new c({ source: s.source, frame: e.frame.clone() })));
|
|
47
48
|
}
|
|
48
49
|
refresh() {
|
|
49
50
|
this.source.update();
|
|
50
51
|
}
|
|
51
52
|
destroy() {
|
|
52
53
|
for (const t of this.frames.values()) t.destroy();
|
|
53
|
-
this.frames.clear(), this.whole.destroy(), this.source.destroy();
|
|
54
|
+
this.frames.clear(), this.whole.destroy(), this.owned && this.source.destroy();
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
|
-
class
|
|
57
|
+
class v {
|
|
57
58
|
textures = /* @__PURE__ */ new Map();
|
|
58
59
|
/** Textures repainted or freed while in use (a rig body, its hand): a copy of one must snapshot it first. */
|
|
59
60
|
live = /* @__PURE__ */ new Set();
|
|
@@ -67,42 +68,42 @@ class m {
|
|
|
67
68
|
}
|
|
68
69
|
/** A new texture holding frame `frame` of `key` as it is painted right now; returns its key (one frame, '0'). */
|
|
69
70
|
snapshot(t, s) {
|
|
70
|
-
const e = this.get(t, s), { x: a, y:
|
|
71
|
-
|
|
71
|
+
const e = this.get(t, s), { x: a, y: i, width: h, height: r } = e.frame, n = document.createElement("canvas");
|
|
72
|
+
n.width = h, n.height = r;
|
|
72
73
|
const o = this.textures.get(t)?.canvas;
|
|
73
|
-
o &&
|
|
74
|
-
const
|
|
75
|
-
return this.addCanvas(
|
|
74
|
+
o && n.getContext("2d").drawImage(o, a, i, h, r, 0, 0, h, r);
|
|
75
|
+
const d = `${t}#still${++this.snapshots}`;
|
|
76
|
+
return this.addCanvas(d, n).add("0", 0, 0, 0, h, r), d;
|
|
76
77
|
}
|
|
77
78
|
/**
|
|
78
79
|
* `snapshot` into a texture kept for reuse (`into`): its canvas is repainted in place and uploaded again, and only
|
|
79
80
|
* made anew when the frame's size changes. Frame '0' is the copy.
|
|
80
81
|
*/
|
|
81
82
|
snapshotInto(t, s, e) {
|
|
82
|
-
const a = this.get(t, s), { x:
|
|
83
|
+
const a = this.get(t, s), { x: i, y: h, width: r, height: n } = a.frame;
|
|
83
84
|
let o = this.textures.get(e);
|
|
84
|
-
if (!o || o.width !== r || o.height !==
|
|
85
|
+
if (!o || o.width !== r || o.height !== n) {
|
|
85
86
|
const g = document.createElement("canvas");
|
|
86
|
-
g.width = r, g.height =
|
|
87
|
+
g.width = r, g.height = n, o = this.addCanvas(e, g), o.add("0", 0, 0, 0, r, n);
|
|
87
88
|
}
|
|
88
|
-
const
|
|
89
|
-
|
|
89
|
+
const d = o.context;
|
|
90
|
+
d.clearRect(0, 0, r, n);
|
|
90
91
|
const w = this.textures.get(t)?.canvas;
|
|
91
|
-
w &&
|
|
92
|
+
w && d.drawImage(w, i, h, r, n, 0, 0, r, n), o.refresh();
|
|
92
93
|
}
|
|
93
94
|
exists(t) {
|
|
94
95
|
return this.textures.has(t);
|
|
95
96
|
}
|
|
96
97
|
addCanvas(t, s) {
|
|
97
98
|
this.remove(t);
|
|
98
|
-
const e = new
|
|
99
|
+
const e = new f(t, s);
|
|
99
100
|
return this.textures.set(t, e), e;
|
|
100
101
|
}
|
|
101
102
|
/** A canvas cut into equal frames named 0, 1, 2... left to right, then row by row. */
|
|
102
103
|
addSpriteSheet(t, s, e) {
|
|
103
|
-
const a = this.addCanvas(t, s),
|
|
104
|
-
for (let r = 0; r <
|
|
105
|
-
a.add(String(r), 0, r %
|
|
104
|
+
const a = this.addCanvas(t, s), i = Math.floor(s.width / e.frameWidth), h = Math.floor(s.height / e.frameHeight);
|
|
105
|
+
for (let r = 0; r < i * h; r++)
|
|
106
|
+
a.add(String(r), 0, r % i * e.frameWidth, Math.floor(r / i) * e.frameHeight, e.frameWidth, e.frameHeight);
|
|
106
107
|
return a;
|
|
107
108
|
}
|
|
108
109
|
/**
|
|
@@ -114,12 +115,23 @@ class m {
|
|
|
114
115
|
for (let a = 1; this.textures.has(`${t}~${a}`); a++)
|
|
115
116
|
this.remove(`${t}~${a}`);
|
|
116
117
|
const e = this.addCanvas(t, s[0].canvas);
|
|
117
|
-
return s.forEach((a,
|
|
118
|
-
const
|
|
118
|
+
return s.forEach((a, i) => {
|
|
119
|
+
const h = i === 0 ? e : this.addCanvas(`${t}~${i}`, a.canvas);
|
|
119
120
|
for (const r of a.frames)
|
|
120
|
-
|
|
121
|
+
h !== e && h.addPacked(r), e.addPacked(r, h);
|
|
121
122
|
}), e;
|
|
122
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* Registers `key` as the rect (x, y, w, h) of the texture `page`, on the page's source: shown by `setTexture(key)`
|
|
126
|
+
* like any texture, and batched with every other view of that page. Null when the page is not registered.
|
|
127
|
+
*/
|
|
128
|
+
addView(t, s, e, a, i, h) {
|
|
129
|
+
const r = this.textures.get(s);
|
|
130
|
+
if (!r) return null;
|
|
131
|
+
this.remove(t);
|
|
132
|
+
const n = new f(t, r.canvas, { source: r.source, frame: new u(e, a, i, h) });
|
|
133
|
+
return this.textures.set(t, n), n;
|
|
134
|
+
}
|
|
123
135
|
createCanvas(t, s, e) {
|
|
124
136
|
const a = document.createElement("canvas");
|
|
125
137
|
return a.width = s, a.height = e, this.addCanvas(t, a);
|
|
@@ -132,10 +144,10 @@ class m {
|
|
|
132
144
|
return e ? s === void 0 || s === "" ? e.whole : e.frames.get(String(s)) ?? this.warn(`${t}/${s}`) : this.warn(t);
|
|
133
145
|
}
|
|
134
146
|
warn(t) {
|
|
135
|
-
return this.missing.has(t) || (this.missing.add(t), console.warn(`[textures] missing ${t}`)),
|
|
147
|
+
return this.missing.has(t) || (this.missing.add(t), console.warn(`[textures] missing ${t}`)), c.EMPTY;
|
|
136
148
|
}
|
|
137
149
|
}
|
|
138
150
|
export {
|
|
139
|
-
|
|
140
|
-
|
|
151
|
+
f as CanvasTexture,
|
|
152
|
+
v as TextureRegistry
|
|
141
153
|
};
|
package/dist/pixel/lifeArt.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const M = {
|
|
2
2
|
leaves: [
|
|
3
3
|
["#7ab04e", "#3d7a36"],
|
|
4
4
|
["#d8a040", "#9a5a24"]
|
|
@@ -22,62 +22,77 @@ const F = {
|
|
|
22
22
|
firefly: ["#f0ff9a", "#a8c850"],
|
|
23
23
|
smoke: ["#b8b0b4", "#9a9296", "#7c7478"]
|
|
24
24
|
}, v = 6;
|
|
25
|
-
function
|
|
25
|
+
function O(o, b) {
|
|
26
26
|
const l = Number.parseInt(o.replace("#", ""), 16);
|
|
27
|
-
return `rgba(${l >> 16 & 255},${l >> 8 & 255},${l & 255},${
|
|
27
|
+
return `rgba(${l >> 16 & 255},${l >> 8 & 255},${l & 255},${b})`;
|
|
28
28
|
}
|
|
29
|
-
function
|
|
30
|
-
const l = [[2, 2], [3, 3], [4, 3], [5, 4], [6, 5], [7, 5]], [
|
|
31
|
-
for (let
|
|
32
|
-
for (let r = 0; r <
|
|
33
|
-
const
|
|
34
|
-
if (
|
|
35
|
-
const
|
|
36
|
-
|
|
29
|
+
function P(o, b = M.smoke) {
|
|
30
|
+
const l = [[2, 2], [3, 3], [4, 3], [5, 4], [6, 5], [7, 5]], [n, c] = l[Math.max(0, Math.min(v - 1, o))], [h, t, _] = b, p = [], f = (n - 1) / 2, m = (c - 1) / 2, $ = o < 3 ? 0.9 : o < 5 ? 0.78 : 0.62;
|
|
31
|
+
for (let d = 0; d < c; d++)
|
|
32
|
+
for (let r = 0; r < n; r++) {
|
|
33
|
+
const e = (r - f) / (n / 2), y = (d - m) / (c / 2), k = (r * 7 + d * 13 + o * 5) % 5 / 10;
|
|
34
|
+
if (e * e + y * y > 0.85 + k || o >= v - 2 && (r + d + o) % 2) continue;
|
|
35
|
+
const g = e + y, u = g < -0.35 ? h : g > 0.45 ? _ : t;
|
|
36
|
+
p.push([r, d, u.startsWith("#") ? O(u, $) : u]);
|
|
37
37
|
}
|
|
38
|
-
return { w:
|
|
38
|
+
return { w: n, h: c, px: p };
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
const _
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return o.addCanvas(e, b), e;
|
|
40
|
+
const A = 64;
|
|
41
|
+
function R(o, b = A) {
|
|
42
|
+
const l = [];
|
|
43
|
+
let n = 0, c = 0, h = 0;
|
|
44
|
+
for (const [t, _] of o)
|
|
45
|
+
n > 0 && n + t > b && (n = 0, c += h + 1, h = 0), l.push([n, c]), n += t + 1, h = Math.max(h, _);
|
|
46
|
+
return { at: l, height: c + h };
|
|
48
47
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
([
|
|
48
|
+
let B = 0;
|
|
49
|
+
function I(o, b, l) {
|
|
50
|
+
const n = l.filter((f) => !o.exists(f.key));
|
|
51
|
+
if (!n.length) return;
|
|
52
|
+
const { at: c, height: h } = R(n.map((f) => [f.w, f.h])), t = document.createElement("canvas");
|
|
53
|
+
t.width = A, t.height = Math.max(1, h);
|
|
54
|
+
const _ = t.getContext("2d");
|
|
55
|
+
n.forEach((f, m) => {
|
|
56
|
+
const [$, d] = c[m];
|
|
57
|
+
for (const [r, e, y] of f.pixels)
|
|
58
|
+
_.fillStyle = y, _.fillRect($ + r, d + e, 1, 1);
|
|
59
|
+
});
|
|
60
|
+
const p = `${b}page${++B}`;
|
|
61
|
+
o.addCanvas(p, t), n.forEach((f, m) => o.addView(f.key, p, c[m][0], c[m][1], f.w, f.h));
|
|
62
|
+
}
|
|
63
|
+
function W(o, b = {}, l = "life_") {
|
|
64
|
+
const n = { ...M, ...b }, c = (s) => l + s, h = [], t = (s, a, i, S, L) => (h.push({ key: a, w: i, h: S, pixels: L }), a), _ = n.leaves.map(([s, a], i) => [
|
|
65
|
+
t(o, c(`leaf_${i}_0`), 2, 1, [[0, 0, s], [1, 0, a]]),
|
|
66
|
+
t(o, c(`leaf_${i}_1`), 2, 2, [[0, 0, s], [1, 1, a]]),
|
|
67
|
+
t(o, c(`leaf_${i}_2`), 1, 2, [[0, 0, s], [0, 1, a]])
|
|
68
|
+
]), p = [
|
|
69
|
+
[t(o, c("seed_0"), 1, 1, [[0, 0, n.seed[0]]])],
|
|
70
|
+
[t(o, c("seed_1"), 2, 1, [[0, 0, n.seed[0]], [1, 0, n.seed[1]]])]
|
|
71
|
+
], f = [n.ember.map((s, a) => t(o, c(`ember_${a}`), 1, 1, [[0, 0, s]]))], m = n.mote.map((s, a) => [t(o, c(`mote_${a}`), 1, 1, [[0, 0, s]])]), $ = n.ash.map(
|
|
72
|
+
([s, a], i) => (
|
|
59
73
|
// the first flake flat, the next tumbling on its corner
|
|
60
|
-
[
|
|
74
|
+
[t(o, c(`ash_${i}`), 2, i % 2 ? 2 : 1, i % 2 ? [[0, 0, s], [1, 1, a]] : [[0, 0, s], [1, 0, a]])]
|
|
61
75
|
)
|
|
62
|
-
),
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
]),
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
], [
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
],
|
|
72
|
-
for (let
|
|
73
|
-
const { w:
|
|
74
|
-
|
|
76
|
+
), d = n.butterflyBody, r = n.butterflies.map(([s, a], i) => [
|
|
77
|
+
t(o, c(`fly_${i}_o`), 3, 2, [[0, 0, s], [2, 0, s], [1, 0, d], [0, 1, a], [1, 1, d], [2, 1, a]]),
|
|
78
|
+
t(o, c(`fly_${i}_c`), 3, 2, [[1, 0, s], [1, 1, a]])
|
|
79
|
+
]), e = n.bird, y = [
|
|
80
|
+
t(o, c("bird_0"), 5, 2, [[0, 0, e], [4, 0, e], [1, 1, e], [2, 1, e], [3, 1, e]]),
|
|
81
|
+
t(o, c("bird_1"), 5, 2, [[0, 1, e], [1, 0, e], [2, 0, e], [3, 0, e], [4, 1, e]])
|
|
82
|
+
], [k, g] = n.birdShadow, u = t(o, c("bird_shadow"), 3, 1, [[0, 0, g], [1, 0, k], [2, 0, g]]), [C, w] = n.firefly, F = [
|
|
83
|
+
t(o, c("firefly_dim"), 3, 3, [[1, 1, w]]),
|
|
84
|
+
t(o, c("firefly_lit"), 3, 3, [[1, 1, C], [0, 1, w], [2, 1, w], [1, 0, w], [1, 2, w]])
|
|
85
|
+
], E = [];
|
|
86
|
+
for (let s = 0; s < v; s++) {
|
|
87
|
+
const { w: a, h: i, px: S } = P(s, n.smoke);
|
|
88
|
+
E.push(t(o, c(`puff_${s}`), a, i, S));
|
|
75
89
|
}
|
|
76
|
-
return { leaves:
|
|
90
|
+
return I(o, l, h), { leaves: _, seeds: p, embers: f, motes: m, ash: $, butterflies: r, bird: y, birdShadow: u, firefly: F, puffs: E };
|
|
77
91
|
}
|
|
78
92
|
export {
|
|
79
|
-
|
|
93
|
+
M as LIFE_COLORS,
|
|
80
94
|
v as PUFF_FRAMES,
|
|
81
|
-
R as
|
|
82
|
-
|
|
95
|
+
R as packShelves,
|
|
96
|
+
W as paintLifeArt,
|
|
97
|
+
P as puffPixels
|
|
83
98
|
};
|
|
@@ -6,9 +6,13 @@ export declare class Group extends Group_base {
|
|
|
6
6
|
add(child: PixiContainer | PixiContainer[]): this;
|
|
7
7
|
addAt(child: PixiContainer, index: number): this;
|
|
8
8
|
remove(child: PixiContainer, destroy?: boolean): this;
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* Puts `child` directly below `other` in the draw order. Already there, it does nothing: taking a child out and
|
|
11
|
+
* putting it back marks the render group's structure changed, and Pixi rebuilds its draw instructions for that
|
|
12
|
+
* frame — a held weapon ordered against its body every frame did it every frame.
|
|
13
|
+
*/
|
|
10
14
|
moveBelow(child: PixiContainer, other: PixiContainer): this;
|
|
11
|
-
/** Puts `child` directly above `other` in the draw order. */
|
|
15
|
+
/** Puts `child` directly above `other` in the draw order; already there, it does nothing (see `moveBelow`). */
|
|
12
16
|
moveAbove(child: PixiContainer, other: PixiContainer): this;
|
|
13
17
|
}
|
|
14
18
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Group.d.ts","sourceRoot":"","sources":["../../../src/core/Group.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,SAAS,IAAI,aAAa,EAAE,MAAM,SAAS,CAAC;;AAGrE,yFAAyF;AACzF,qBAAa,KAAM,SAAQ,UAAqB;IAC9C,IAAI,IAAI,IAAI,aAAa,EAAE,CAE1B;IAED,GAAG,CAAC,KAAK,EAAE,aAAa,GAAG,aAAa,EAAE,GAAG,IAAI;IAKjD,KAAK,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAKhD,MAAM,CAAC,KAAK,EAAE,aAAa,EAAE,OAAO,UAAQ,GAAG,IAAI;IAMnD
|
|
1
|
+
{"version":3,"file":"Group.d.ts","sourceRoot":"","sources":["../../../src/core/Group.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,SAAS,IAAI,aAAa,EAAE,MAAM,SAAS,CAAC;;AAGrE,yFAAyF;AACzF,qBAAa,KAAM,SAAQ,UAAqB;IAC9C,IAAI,IAAI,IAAI,aAAa,EAAE,CAE1B;IAED,GAAG,CAAC,KAAK,EAAE,aAAa,GAAG,aAAa,EAAE,GAAG,IAAI;IAKjD,KAAK,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAKhD,MAAM,CAAC,KAAK,EAAE,aAAa,EAAE,OAAO,UAAQ,GAAG,IAAI;IAMnD;;;;OAIG;IACH,SAAS,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,aAAa,GAAG,IAAI;IAQ3D,+GAA+G;IAC/G,SAAS,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,aAAa,GAAG,IAAI;CAO5D"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CanvasSource, Texture } from 'pixi.js';
|
|
1
|
+
import { CanvasSource, Rectangle, Texture } from 'pixi.js';
|
|
2
2
|
/** A frame packed on an atlas page (TexturePacker and the like), as `assets/textureAtlas.ts` parses it. */
|
|
3
3
|
export interface PackedFrame {
|
|
4
4
|
name: string;
|
|
@@ -25,14 +25,23 @@ export interface PackedFrame {
|
|
|
25
25
|
y: number;
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* A canvas-backed texture with named frames; repaint the canvas, then `refresh()` to upload it. Made with a `view`, it
|
|
30
|
+
* is one rect of another texture's canvas on that texture's own source (`TextureRegistry.addView`): small pieces
|
|
31
|
+
* swapped every few frames then batch together, where a source each made Pixi rebuild its draw instructions at every
|
|
32
|
+
* swap.
|
|
33
|
+
*/
|
|
29
34
|
export declare class CanvasTexture {
|
|
30
35
|
readonly key: string;
|
|
31
36
|
readonly canvas: HTMLCanvasElement;
|
|
32
37
|
readonly frames: Map<string, Texture<import("pixi.js").TextureSource<any>>>;
|
|
33
38
|
readonly source: CanvasSource;
|
|
34
39
|
readonly whole: Texture;
|
|
35
|
-
|
|
40
|
+
private readonly owned;
|
|
41
|
+
constructor(key: string, canvas: HTMLCanvasElement, view?: {
|
|
42
|
+
source: CanvasSource;
|
|
43
|
+
frame: Rectangle;
|
|
44
|
+
});
|
|
36
45
|
get width(): number;
|
|
37
46
|
get height(): number;
|
|
38
47
|
get context(): CanvasRenderingContext2D;
|
|
@@ -82,6 +91,11 @@ export declare class TextureRegistry {
|
|
|
82
91
|
canvas: HTMLCanvasElement;
|
|
83
92
|
frames: readonly PackedFrame[];
|
|
84
93
|
}[]): CanvasTexture;
|
|
94
|
+
/**
|
|
95
|
+
* Registers `key` as the rect (x, y, w, h) of the texture `page`, on the page's source: shown by `setTexture(key)`
|
|
96
|
+
* like any texture, and batched with every other view of that page. Null when the page is not registered.
|
|
97
|
+
*/
|
|
98
|
+
addView(key: string, page: string, x: number, y: number, w: number, h: number): CanvasTexture | null;
|
|
85
99
|
createCanvas(key: string, width: number, height: number): CanvasTexture;
|
|
86
100
|
remove(key: string): void;
|
|
87
101
|
get(key: string, frame?: string | number): Texture;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextureRegistry.d.ts","sourceRoot":"","sources":["../../../src/core/TextureRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"TextureRegistry.d.ts","sourceRoot":"","sources":["../../../src/core/TextureRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAE3D,2GAA2G;AAC3G,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,iFAAiF;IACjF,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,oEAAoE;IACpE,OAAO,EAAE,OAAO,CAAC;IACjB,wCAAwC;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,uGAAuG;IACvG,IAAI,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACtD,yDAAyD;IACzD,MAAM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M,GAAG,MAAM,GAAG,OAAO;IAOlD,OAAO,CAAC,IAAI;CAOb"}
|
|
@@ -55,6 +55,14 @@ export declare function puffPixels(frame: number, colors?: readonly [string, str
|
|
|
55
55
|
h: number;
|
|
56
56
|
px: LifePixel[];
|
|
57
57
|
};
|
|
58
|
+
/**
|
|
59
|
+
* Where each of `sizes` goes on one page `width` wide: left to right, a new row below the tallest of the last when the
|
|
60
|
+
* next does not fit, one clear pixel between pieces (so nothing bleeds into a neighbour). Also the page's height.
|
|
61
|
+
*/
|
|
62
|
+
export declare function packShelves(sizes: readonly (readonly [w: number, h: number])[], width?: number): {
|
|
63
|
+
at: [number, number][];
|
|
64
|
+
height: number;
|
|
65
|
+
};
|
|
58
66
|
/**
|
|
59
67
|
* Paints the life's art under `prefix` (default `'life_'`) and returns its keys. A key already registered is kept, so
|
|
60
68
|
* calling it again (every map) costs nothing — and painting other colours needs another prefix.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifeArt.d.ts","sourceRoot":"","sources":["../../../src/pixel/lifeArt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAS/D,kDAAkD;AAClD,MAAM,MAAM,SAAS,GAAG,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AAEvE,8FAA8F;AAC9F,MAAM,WAAW,UAAU;IACzB,mCAAmC;IACnC,MAAM,EAAE,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC;IAC/C,qEAAqE;IACrE,IAAI,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,iCAAiC;IACjC,KAAK,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,iBAAiB;IACjB,IAAI,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,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,MAAM,CAAC,CAAC,EAAE,EAAE,KAAK,SAAS,GAAG;IAAE,EAAE,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAgB3I;AAoCD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,eAAe,EAAE,MAAM,GAAE,OAAO,CAAC,UAAU,CAAM,EAAE,MAAM,SAAU,GAAG,OAAO,CAkDnH"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "1681-engine",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.6",
|
|
4
4
|
"description": "A 2D game engine on PixiJS 8 for any art style: scenes and a fast ECS, a fixed-step loop, asset loading, Tiled maps, sprite animation, input actions, camera follow, audio and deterministic, server-replayable movement, plus Dither, an optional pixel-art module (pixel-perfect effects, dithered lighting).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/types/index.d.ts",
|