Worker orbs: excitement kick when a worker flips active
The inactive->active transition (caught at the existing 30-frame state refresh) now jolts the orb: a random-direction velocity kick with a briefly lifted speed cap so it actually darts, a fast shallow size wobble (~1s decay), and three sparks. A worker waking up reads as 'it sprang into action' instead of just getting brighter.
This commit is contained in:
parent
4082803d78
commit
01ae63f0d5
1 changed files with 23 additions and 3 deletions
|
|
@ -121,6 +121,7 @@
|
||||||
z: 0,
|
z: 0,
|
||||||
zPhase: Math.random() * Math.PI * 2,
|
zPhase: Math.random() * Math.PI * 2,
|
||||||
zSpeed: 0.22 + Math.random() * 0.18,
|
zSpeed: 0.22 + Math.random() * 0.18,
|
||||||
|
kick: 0, // excitement-kick energy (decays)
|
||||||
active: false,
|
active: false,
|
||||||
statusSeen: false, // has a real WS status arrived for this worker?
|
statusSeen: false, // has a real WS status arrived for this worker?
|
||||||
lastProcessed: 0, // cumulative matched+not_found seen last update
|
lastProcessed: 0, // cumulative matched+not_found seen last update
|
||||||
|
|
@ -582,7 +583,20 @@
|
||||||
if (frameCount % 30 === 0) {
|
if (frameCount % 30 === 0) {
|
||||||
orbs.forEach(orb => {
|
orbs.forEach(orb => {
|
||||||
orb.visible = orb.el.offsetParent !== null;
|
orb.visible = orb.el.offsetParent !== null;
|
||||||
orb.active = orb.btn ? orb.btn.classList.contains('active') : false;
|
const nowActive = orb.btn ? orb.btn.classList.contains('active') : false;
|
||||||
|
if (nowActive && !orb.active && !orb.hub) {
|
||||||
|
// Excitement kick: a freshly-woken worker jolts into motion
|
||||||
|
// (brief overspeed + size wobble + a few sparks) instead of
|
||||||
|
// just getting brighter. Decays in physics/draw.
|
||||||
|
const ang = Math.random() * Math.PI * 2;
|
||||||
|
orb.vx += Math.cos(ang) * 1.6;
|
||||||
|
orb.vy += Math.sin(ang) * 1.6;
|
||||||
|
orb.kick = 1.0;
|
||||||
|
for (let i = 0; i < 3; i++) {
|
||||||
|
emitSpark(orb, orb.rainbow ? getRainbowColor(time) : null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
orb.active = nowActive;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -714,8 +728,10 @@
|
||||||
orb.vx *= 0.993;
|
orb.vx *= 0.993;
|
||||||
orb.vy *= 0.993;
|
orb.vy *= 0.993;
|
||||||
|
|
||||||
// Speed cap — active orbs move a bit faster
|
// Speed cap — active orbs move a bit faster; an excitement kick
|
||||||
const maxSpeed = orb.active ? 0.8 : 0.5;
|
// briefly lifts the cap so the jolt actually darts, then decays.
|
||||||
|
orb.kick = (orb.kick || 0) * 0.94;
|
||||||
|
const maxSpeed = (orb.active ? 0.8 : 0.5) * (1 + orb.kick * 2);
|
||||||
const speed = Math.sqrt(orb.vx * orb.vx + orb.vy * orb.vy);
|
const speed = Math.sqrt(orb.vx * orb.vx + orb.vy * orb.vy);
|
||||||
if (speed > maxSpeed) {
|
if (speed > maxSpeed) {
|
||||||
const scale = maxSpeed / speed;
|
const scale = maxSpeed / speed;
|
||||||
|
|
@ -881,6 +897,10 @@
|
||||||
if (orb.active) {
|
if (orb.active) {
|
||||||
baseRadius += 2 * Math.sin(time * 3 + orb.phase);
|
baseRadius += 2 * Math.sin(time * 3 + orb.phase);
|
||||||
}
|
}
|
||||||
|
// Excitement-kick wobble: fast, shallow, gone in under a second
|
||||||
|
if (orb.kick > 0.02) {
|
||||||
|
baseRadius += orb.kick * 2.5 * Math.sin(time * 14 + orb.phase);
|
||||||
|
}
|
||||||
|
|
||||||
// Scale up during expand transition; depth scales the whole orb
|
// Scale up during expand transition; depth scales the whole orb
|
||||||
const currentRadius = (state === 'expanding'
|
const currentRadius = (state === 'expanding'
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue