@painekillers/tree-builder-core 1.1.1 → 1.2.1
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 +1 -1
- package/themes/dark.js +21 -7
- package/themes/default.js +21 -7
- package/world/bridge.js +2 -1
- package/world/objects.js +31 -8
package/package.json
CHANGED
package/themes/dark.js
CHANGED
|
@@ -58,6 +58,7 @@ export default {
|
|
|
58
58
|
|
|
59
59
|
node(ctx, object) {
|
|
60
60
|
const pos = object.pos
|
|
61
|
+
const tile = object.tile
|
|
61
62
|
const size = object.size
|
|
62
63
|
|
|
63
64
|
const width = size.width * object.scale
|
|
@@ -104,13 +105,26 @@ export default {
|
|
|
104
105
|
|
|
105
106
|
ctx.globalAlpha = object.hovered ? 1 : 0.92
|
|
106
107
|
|
|
107
|
-
ctx.
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
108
|
+
ctx.imageSmoothingEnabled = false;
|
|
109
|
+
|
|
110
|
+
if (tile) {
|
|
111
|
+
ctx.drawImage(
|
|
112
|
+
object.image,
|
|
113
|
+
tile.x, tile.y, tile.width, tile.height,
|
|
114
|
+
x,
|
|
115
|
+
y,
|
|
116
|
+
width,
|
|
117
|
+
height,
|
|
118
|
+
)
|
|
119
|
+
} else {
|
|
120
|
+
ctx.drawImage(
|
|
121
|
+
object.image,
|
|
122
|
+
x,
|
|
123
|
+
y,
|
|
124
|
+
width,
|
|
125
|
+
height,
|
|
126
|
+
)
|
|
127
|
+
}
|
|
114
128
|
|
|
115
129
|
ctx.restore()
|
|
116
130
|
|
package/themes/default.js
CHANGED
|
@@ -140,6 +140,7 @@ export default {
|
|
|
140
140
|
node(ctx, object) {
|
|
141
141
|
const pos = object.pos
|
|
142
142
|
const size = object.size
|
|
143
|
+
const tile = object.tile
|
|
143
144
|
|
|
144
145
|
const width = size.width * object.scale
|
|
145
146
|
const height = size.height * object.scale
|
|
@@ -173,13 +174,26 @@ export default {
|
|
|
173
174
|
|
|
174
175
|
ctx.globalAlpha = object.hovered ? 1 : 0.92
|
|
175
176
|
|
|
176
|
-
ctx.
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
177
|
+
ctx.imageSmoothingEnabled = false;
|
|
178
|
+
|
|
179
|
+
if (tile) {
|
|
180
|
+
ctx.drawImage(
|
|
181
|
+
object.image,
|
|
182
|
+
tile.x, tile.y, tile.width, tile.height,
|
|
183
|
+
x,
|
|
184
|
+
y,
|
|
185
|
+
width,
|
|
186
|
+
height,
|
|
187
|
+
)
|
|
188
|
+
} else {
|
|
189
|
+
ctx.drawImage(
|
|
190
|
+
object.image,
|
|
191
|
+
x,
|
|
192
|
+
y,
|
|
193
|
+
width,
|
|
194
|
+
height,
|
|
195
|
+
)
|
|
196
|
+
}
|
|
183
197
|
|
|
184
198
|
ctx.restore()
|
|
185
199
|
|
package/world/bridge.js
CHANGED
package/world/objects.js
CHANGED
|
@@ -100,11 +100,13 @@ placeholder.src = "data:image/svg+xml," + encodeURIComponent(`
|
|
|
100
100
|
|
|
101
101
|
export class ImageInstance extends PSInstance {
|
|
102
102
|
#image
|
|
103
|
+
#tile
|
|
103
104
|
|
|
104
|
-
constructor(world, x, y, width, height, image) {
|
|
105
|
+
constructor(world, x, y, width, height, image, tile) {
|
|
105
106
|
super(world, x, y, width, height)
|
|
106
107
|
|
|
107
108
|
this.image = image
|
|
109
|
+
this.#tile = tile ?? null
|
|
108
110
|
}
|
|
109
111
|
|
|
110
112
|
set image(img) {
|
|
@@ -116,17 +118,37 @@ export class ImageInstance extends PSInstance {
|
|
|
116
118
|
return this.#image ?? placeholder
|
|
117
119
|
}
|
|
118
120
|
|
|
121
|
+
set tile(t) {
|
|
122
|
+
this.#tile = t
|
|
123
|
+
this.world.update()
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
get tile() {
|
|
127
|
+
return this.#tile
|
|
128
|
+
}
|
|
129
|
+
|
|
119
130
|
draw(ctx, p, s) {
|
|
120
131
|
let pos = p || this.pos
|
|
121
132
|
let size = s || this.size
|
|
122
133
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
134
|
+
if (this.#tile) {
|
|
135
|
+
ctx.drawImage(
|
|
136
|
+
this.image,
|
|
137
|
+
this.#tile.x, this.#tile.y, this.#tile.width, this.#tile.height,
|
|
138
|
+
pos.x - size.width / 2,
|
|
139
|
+
pos.y - size.height / 2,
|
|
140
|
+
size.width,
|
|
141
|
+
size.height,
|
|
142
|
+
)
|
|
143
|
+
} else {
|
|
144
|
+
ctx.drawImage(
|
|
145
|
+
this.image,
|
|
146
|
+
pos.x - size.width / 2,
|
|
147
|
+
pos.y - size.height / 2,
|
|
148
|
+
size.width,
|
|
149
|
+
size.height,
|
|
150
|
+
)
|
|
151
|
+
}
|
|
130
152
|
}
|
|
131
153
|
}
|
|
132
154
|
|
|
@@ -144,6 +166,7 @@ export class Line extends Object {
|
|
|
144
166
|
}
|
|
145
167
|
}
|
|
146
168
|
|
|
169
|
+
// Probably wanna change how this works too !!!!!!!!!!!
|
|
147
170
|
export class NodeInstance extends ImageInstance {
|
|
148
171
|
constructor(world, x, y, width, height, node, image, drawNode) {
|
|
149
172
|
super(world, x, y, width, height, image)
|