World sounds are heard in a radius around the bot, not the view
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+10
-7
@@ -26,15 +26,18 @@ with sync_playwright() as p:
|
||||
pg.wait_for_timeout(500)
|
||||
ev = pg.evaluate
|
||||
ev("window._maxStatus = ''; const _ss = setStatus; setStatus = function (s, k) { if (s && s.length > _maxStatus.length) _maxStatus = s; return _ss(s, k); }; 0")
|
||||
# World effects use the view, and inaudible ones must not throttle nearby sounds.
|
||||
# World sounds are heard around the bot at any zoom, and inaudible ones must not throttle nearby sounds.
|
||||
ev("auInit(); window._noiseCalls = 0; window._noiseBurst = noiseBurst; noiseBurst = function (...args) { _noiseCalls++; return _noiseBurst(...args); }; 0")
|
||||
ev("window._bc = (dx, dy) => [bot.x + bot.w / 2 + dx, bot.y + bot.h / 2 + dy]; 0")
|
||||
try:
|
||||
far = ev("(() => { const n = _noiseCalls; AU.last.sizzle = 0; const x = R.vx0 + R.bw * 3, y = R.vy0 + R.bh / 2; playSfx('sizzle', 0, x, y); return [_noiseCalls - n, sfxPlace(x, y).gain, AU.last.sizzle]; })()")
|
||||
check('a sound far off-screen is silent', far == [0, 0, 0], far)
|
||||
near = ev("(() => { const n = _noiseCalls; AU.last.sizzle = 0; const x = R.vx0 + R.bw / 2, y = R.vy0 + R.bh / 2; playSfx('sizzle', 0, x, y); return [_noiseCalls - n, sfxPlace(x, y).gain, AU.bus == null]; })()")
|
||||
check('a sound on screen plays', near == [1, 1, True], near)
|
||||
quiet = ev('sfxPlace(R.vx0 + R.bw * 1.5, R.vy0 + R.bh / 2)')
|
||||
check('a sound just off-screen is quieter', 0 < quiet['gain'] < 1 and quiet['pan'] > 0, quiet)
|
||||
far = ev("(() => { const n = _noiseCalls; AU.last.sizzle = 0; const [x, y] = _bc(200, 0); playSfx('sizzle', 0, x, y); return [_noiseCalls - n, sfxPlace(x, y).gain, AU.last.sizzle]; })()")
|
||||
check('a sound 200 grains from the bot is silent', far == [0, 0, 0], far)
|
||||
near = ev("(() => { const n = _noiseCalls; AU.last.sizzle = 0; const [x, y] = _bc(10, 0); playSfx('sizzle', 0, x, y); return [_noiseCalls - n, sfxPlace(x, y).gain, AU.bus == null]; })()")
|
||||
check('a sound next to the bot plays at full volume', near == [1, 1, True], near)
|
||||
quiet = ev('sfxPlace(..._bc(60, 0))')
|
||||
check('a sound 60 grains to the right is quieter and panned right', 0 < quiet['gain'] < 1 and quiet['pan'] > 0, quiet)
|
||||
zoomed = ev("(() => { const z = SET.zoom; SET.zoom = 2; resizeRender(); const n = _noiseCalls; AU.last.sizzle = 0; const [x, y] = _bc(200, 0); const vis = x < R.vx0 + R.bw; playSfx('sizzle', 0, x, y); SET.zoom = z; resizeRender(); return [vis, _noiseCalls - n]; })()")
|
||||
check('zoomed far out, a visible sound 200 grains away stays silent', zoomed == [True, 0], zoomed)
|
||||
finally:
|
||||
ev('noiseBurst = _noiseBurst; delete window._noiseBurst; delete window._noiseCalls; 0')
|
||||
look = sys.argv[2] if len(sys.argv) > 2 else 'pixel'
|
||||
|
||||
Reference in New Issue
Block a user