From 56e5db68988d1abfa2570d8c2ec48a7b37fab502 Mon Sep 17 00:00:00 2001 From: cha0s Date: Wed, 26 Jun 2024 04:18:54 -0500 Subject: [PATCH] fun: dirt --- public/assets/hoe/start.js | 99 +++++++++++++++++++++++++++++++++++++- 1 file changed, 98 insertions(+), 1 deletion(-) diff --git a/public/assets/hoe/start.js b/public/assets/hoe/start.js index 47e4568..f964404 100644 --- a/public/assets/hoe/start.js +++ b/public/assets/hoe/start.js @@ -1,4 +1,4 @@ -const {Controlled, Position, Sound, Sprite, Wielder} = wielder +const {Controlled, Emitter, Position, Sound, Sprite, Wielder} = wielder const {TileLayers} = ecs.get(1) const layer = TileLayers.layer(0) const projected = Wielder.project(Position.tile, item.tool.projection) @@ -6,8 +6,105 @@ const projected = Wielder.project(Position.tile, item.tool.projection) Controlled.locked = 1; const [, direction] = Sprite.animation.split(':'); +const dirtParticles = { + behaviors: [ + { + type: 'moveAcceleration', + config: { + accel: { + x: 0, + y: 200, + }, + minStart: 0, + maxStart: 0, + rotate: false, + } + }, + { + type: 'moveSpeed', + config: { + speed: { + list: [ + { + time: 0, + value: 60 + }, + { + time: 1, + value: 10 + } + ] + } + } + }, + { + type: 'rotation', + config: { + accel: 0, + minSpeed: 0, + maxSpeed: 0, + minStart: 225, + maxStart: 320 + } + }, + { + type: 'scale', + config: { + scale: { + list: [ + { + value: 0.25, + time: 0, + }, + { + value: 0.125, + time: 1, + }, + ] + } + } + }, + { + type: 'textureSingle', + config: { + texture: 'tileset/7', + } + }, + ], + lifetime: { + min: 0.25, + max: 0.25, + }, + frequency: 0.01, + emitterLifetime: 0.25, + pos: { + x: 0, + y: 0 + }, +}; + for (let i = 0; i < 2; ++i) { Sound.play('/assets/hoe/dig.wav'); + for (let i = 0; i < projected.length; ++i) { + Emitter.emit({ + ...dirtParticles, + behaviors: [ + ...dirtParticles.behaviors, + { + type: 'spawnShape', + config: { + type: 'rect', + data: { + x: projected[i].x * layer.tileSize.x, + y: projected[i].y * layer.tileSize.y, + w: layer.tileSize.x, + h: layer.tileSize.y, + } + } + } + ] + }) + } Sprite.animation = ['moving', direction].join(':'); await wait(300) Sprite.animation = ['idle', direction].join(':');