fix: subtle torch/campfire flicker, stable warm glow overlay

This commit is contained in:
Mk 2026-05-26 18:16:58 +00:00
parent d948b1743d
commit a5f9ac841f
2 changed files with 7 additions and 7 deletions

12
game.js
View File

@ -3862,7 +3862,7 @@ registerProcessor('voice-playback', VoicePlaybackProcessor);
function drawFire(wx,wy,now){ function drawFire(wx,wy,now){
const baseX = wx; const baseX = wx;
const baseY = wy; const baseY = wy;
const flick = 6 + (Math.sin(now/90)+1)*4; const flick = 1.5 + (Math.sin(now/200)+1)*1;
ctx.fillStyle = 'rgba(255,140,0,0.85)'; ctx.fillStyle = 'rgba(255,140,0,0.85)';
ctx.beginPath(); ctx.beginPath();
ctx.moveTo(baseX+10, baseY+30); ctx.moveTo(baseX+10, baseY+30);
@ -4962,7 +4962,7 @@ registerProcessor('voice-playback', VoicePlaybackProcessor);
// Функция: рисуем мягкий луч света с затуханием за стенами // Функция: рисуем мягкий луч света с затуханием за стенами
function castLight(sx, sy, radius) { function castLight(sx, sy, radius) {
const flick = 0.92 + Math.sin(now/80 + sx*0.01)*0.04 + Math.sin(now/130 + sy*0.02)*0.04; const flick = 0.97 + Math.sin(now/300 + sx*0.01)*0.015 + Math.sin(now/470 + sy*0.02)*0.015;
const r = radius * flick; const r = radius * flick;
// 24 луча — мягкий круглый свет // 24 луча — мягкий круглый свет
const steps = 24; const steps = 24;
@ -5032,13 +5032,13 @@ registerProcessor('voice-playback', VoicePlaybackProcessor);
if(b.gx < minGX-3 || b.gx > maxGX+3 || b.gy < minGY-3 || b.gy > maxGY+3) continue; if(b.gx < minGX-3 || b.gx > maxGX+3 || b.gy < minGY-3 || b.gy > maxGY+3) continue;
const def = BLOCKS[b.t]; const def = BLOCKS[b.t];
if(def.lightRadius){ if(def.lightRadius){
const flick = 0.7 + Math.sin(now/90 + b.gx*3.7)*0.15 + Math.sin(now/140 + b.gy*2.3)*0.15; const flick = 0.9 + Math.sin(now/350 + b.gx*3.7)*0.05 + Math.sin(now/530 + b.gy*2.3)*0.05;
const wx = b.gx*TILE + TILE/2 - camX; const wx = b.gx*TILE + TILE/2 - camX;
const wy = b.gy*TILE + TILE/2 - camY; const wy = b.gy*TILE + TILE/2 - camY;
const r = def.lightRadius * 0.75 * flick; const r = def.lightRadius * 0.85;
const grad = ctx.createRadialGradient(wx,wy, 0, wx,wy, r); const grad = ctx.createRadialGradient(wx,wy, 0, wx,wy, r);
grad.addColorStop(0, `rgba(255,180,80,${0.22*flick})`); grad.addColorStop(0, `rgba(255,180,80,0.28)`);
grad.addColorStop(0.5, `rgba(255,140,40,${0.10*flick})`); grad.addColorStop(0.5, `rgba(255,140,40,0.13)`);
grad.addColorStop(1, 'rgba(255,100,20,0)'); grad.addColorStop(1, 'rgba(255,100,20,0)');
ctx.fillStyle = grad; ctx.fillStyle = grad;
ctx.beginPath(); ctx.beginPath();

View File

@ -94,6 +94,6 @@
</div> </div>
</div> </div>
<script src="game.js?v=26"></script> <script src="game.js?v=27"></script>
</body> </body>
</html> </html>