silphius/public/assets/hoe/start.js

68 lines
1.7 KiB
JavaScript
Raw Normal View History

2024-06-28 08:53:20 -05:00
const {Direction, Position, Wielder} = wielder
2024-07-24 09:28:35 -05:00
const projected = Wielder.activeItem()?.project(Position.tile, Direction.quantize(4))
2024-06-28 08:53:20 -05:00
if (projected?.length > 0) {
2024-06-25 10:44:37 -05:00
2024-06-26 09:17:35 -05:00
const {Controlled, Emitter, Sound, Sprite} = wielder
const {TileLayers} = ecs.get(1)
const layer = TileLayers.layer(0)
2024-06-25 10:44:37 -05:00
2024-06-26 09:17:35 -05:00
Controlled.locked = 1
const [, direction] = Sprite.animation.split(':')
for (let i = 0; i < 2; ++i) {
Sound.play('/assets/hoe/dig.wav');
2024-07-12 17:41:55 -05:00
for (const {x, y} of projected) {
2024-06-26 09:17:35 -05:00
Emitter.emit({
2024-08-01 00:39:54 -05:00
count: 75,
fields: [
{
path: ['Sprite', 'lightness'],
value: [0.05, 0.25],
},
{
path: ['Sprite', 'alpha'],
value: [0.3, 1],
},
{
path: ['Sprite', 'scaleX'],
value: [0.05, 0.3],
},
{
path: ['Sprite', 'scaleY'],
value: [0.05, 0.3],
},
],
frequency: 0.004,
2024-07-30 09:56:53 -05:00
shape: {
type: 'filledRect',
payload: {width: 16, height: 16},
},
entity: {
2024-08-01 00:39:54 -05:00
Forces: {forceY: -40},
2024-07-30 09:56:53 -05:00
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},
}
});
2024-06-26 09:17:35 -05:00
}
Sprite.animation = ['moving', direction].join(':');
2024-06-28 13:10:14 -05:00
await wait(0.3)
2024-06-26 09:17:35 -05:00
Sprite.animation = ['idle', direction].join(':');
2024-06-28 13:10:14 -05:00
await wait(0.1)
2024-06-26 04:18:54 -05:00
}
2024-06-25 10:44:37 -05:00
2024-07-12 17:41:55 -05:00
for (const position of projected) {
TileLayers.layer(1).stamp(position, [[7]])
2024-06-25 10:44:37 -05:00
}
2024-06-26 09:17:35 -05:00
Controlled.locked = 0;
}