50 lines
1.3 KiB
JavaScript
50 lines
1.3 KiB
JavaScript
const {Direction, Position, Wielder} = wielder
|
|
const projected = Wielder.activeItem()?.project(Position.tile, Direction.quantize(4))
|
|
if (projected?.length > 0) {
|
|
|
|
const {Controlled, Emitter, Sound, Sprite} = wielder
|
|
const {TileLayers} = ecs.get(1)
|
|
const layer = TileLayers.layer(0)
|
|
|
|
Controlled.locked = 1
|
|
const [, direction] = Sprite.animation.split(':')
|
|
|
|
for (let i = 0; i < 2; ++i) {
|
|
Sound.play('/assets/hoe/dig.wav');
|
|
for (const {x, y} of projected) {
|
|
Emitter.emit({
|
|
count: 25,
|
|
frequency: 0.01,
|
|
shape: {
|
|
type: 'filledRect',
|
|
payload: {width: 16, height: 16},
|
|
},
|
|
entity: {
|
|
Forces: {forceY: -50},
|
|
Position: {
|
|
x: x * layer.tileSize.x + (layer.tileSize.x / 2),
|
|
y: y * layer.tileSize.y + (layer.tileSize.y / 2),
|
|
},
|
|
Sprite: {
|
|
scaleX: 0.2,
|
|
scaleY: 0.2,
|
|
tint: 0x552200,
|
|
},
|
|
Ttl: {ttl: 0.125},
|
|
}
|
|
});
|
|
}
|
|
Sprite.animation = ['moving', direction].join(':');
|
|
await wait(0.3)
|
|
Sprite.animation = ['idle', direction].join(':');
|
|
await wait(0.1)
|
|
}
|
|
|
|
for (const position of projected) {
|
|
TileLayers.layer(1).stamp(position, [[7]])
|
|
}
|
|
|
|
Controlled.locked = 0;
|
|
|
|
}
|