silphius/resources/brush/start.js
2024-09-17 01:25:39 -05:00

111 lines
2.3 KiB
JavaScript

const {Collider, Controlled, Interacts, Inventory, Sound, Sprite} = wielder
const entities = Collider.closest(Interacts.aabb());
for (const entity of entities) {
const {Emitter, Position, Tags} = entity;
if (Tags && Tags.has('kittan')) {
Controlled.locked = 1
const [, direction] = Sprite.animation.split(':')
for (let i = 0; i < 2; ++i) {
Sound.play('/resources/brush/brush.wav');
Sprite.animation = ['moving', direction].join(':');
await wait(0.3)
Sprite.animation = ['idle', direction].join(':');
await wait(0.1)
}
Inventory.give({
qty: 1,
source: '/resources/furball/furball.json',
});
Controlled.locked = 0;
const heartParticles = {
behaviors: [
{
type: 'moveAcceleration',
config: {
accel: {
x: 0,
y: -100,
},
minStart: 0,
maxStart: 0,
rotate: false,
}
},
{
type: 'moveSpeed',
config: {
speed: {
list: [
{
time: 0,
value: 30
},
{
time: 1,
value: 0
}
]
}
}
},
{
type: 'scale',
config: {
scale: {
list: [
{
value: 0.5,
time: 0,
},
{
value: 0.125,
time: 1,
},
]
}
}
},
{
type: 'textureSingle',
config: {
texture: '/resources/heart/heart.png',
}
},
],
lifetime: {
min: 0.5,
max: 0.5,
},
frequency: 0.1,
emitterLifetime: 0.25,
pos: {
x: 0,
y: 0
},
rotation: 180,
};
Emitter.emit({
...heartParticles,
behaviors: [
...heartParticles.behaviors,
{
type: 'spawnShape',
config: {
type: 'rect',
data: {
x: Position.x - 8,
y: Position.y,
w: 16,
h: 1,
}
}
}
]
})
break;
}
}