fix: brighter torch/campfire light, 24 rays, wider radius, warmer glow

This commit is contained in:
Mk 2026-05-26 13:10:55 +00:00
parent 5774a41761
commit a59c84535a
2 changed files with 11 additions and 11 deletions

20
game.js
View File

@ -644,8 +644,8 @@ function customConfirm(msg, onYes) {
diamond_ore:{n:'Алмаз', c:'#00a8ff', solid:true }, diamond_ore:{n:'Алмаз', c:'#00a8ff', solid:true },
brick: { n:'Кирпич', c:'#c0392b', solid:true }, brick: { n:'Кирпич', c:'#c0392b', solid:true },
tnt: { n:'TNT', c:'#e74c3c', solid:true, explosive:true }, tnt: { n:'TNT', c:'#e74c3c', solid:true, explosive:true },
campfire: { n:'Костёр', c:'#e67e22', solid:true, lightRadius:190 }, campfire: { n:'Костёр', c:'#e67e22', solid:true, lightRadius:280 },
torch: { n:'Факел', c:'#f9ca24', solid:true, lightRadius:140 }, torch: { n:'Факел', c:'#f9ca24', solid:true, lightRadius:220 },
bedrock: { n:'Бедрок', c:'#2d3436', solid:true, unbreakable:true }, bedrock: { n:'Бедрок', c:'#2d3436', solid:true, unbreakable:true },
flower: { n:'Цветок', c:'#ff4757', solid:false, decor:true }, flower: { n:'Цветок', c:'#ff4757', solid:false, decor:true },
bed: { n:'Кровать', c:'#e91e63', solid:true, bed:true }, bed: { n:'Кровать', c:'#e91e63', solid:true, bed:true },
@ -3621,10 +3621,10 @@ function customConfirm(msg, onYes) {
// Функция: рисуем мягкий луч света с затуханием за стенами // Функция: рисуем мягкий луч света с затуханием за стенами
function castLight(sx, sy, radius) { function castLight(sx, sy, radius) {
const flick = 0.88 + Math.sin(now/80 + sx*0.01)*0.06 + Math.sin(now/130 + sy*0.02)*0.06; const flick = 0.92 + Math.sin(now/80 + sx*0.01)*0.04 + Math.sin(now/130 + sy*0.02)*0.04;
const r = radius * flick; const r = radius * flick;
// 12 лучей — достаточно для мягкого круга // 24 луча — мягкий круглый свет
const steps = 12; const steps = 24;
// Собираем дистанции до стен по лучам // Собираем дистанции до стен по лучам
const dists = new Float32Array(steps); const dists = new Float32Array(steps);
for(let i=0; i<steps; i++){ for(let i=0; i<steps; i++){
@ -3633,7 +3633,7 @@ function customConfirm(msg, onYes) {
const dy = Math.sin(angle); const dy = Math.sin(angle);
let maxDist = r; let maxDist = r;
// Идём по лучу пока не упрёмся в стену // Идём по лучу пока не упрёмся в стену
for(let step=TILE*0.5; step<r; step+=TILE*0.6){ for(let step=TILE*0.3; step<r; step+=TILE*0.35){
const gx = Math.floor((sx + dx*step)/TILE); const gx = Math.floor((sx + dx*step)/TILE);
const gy = Math.floor((sy + dy*step)/TILE); const gy = Math.floor((sy + dy*step)/TILE);
const blk = getBlock(gx, gy); const blk = getBlock(gx, gy);
@ -3650,7 +3650,7 @@ function customConfirm(msg, onYes) {
const maxR = Math.max(...dists); const maxR = Math.max(...dists);
const grad = lightCtx.createRadialGradient(cx, cy, 0, cx, cy, maxR); const grad = lightCtx.createRadialGradient(cx, cy, 0, cx, cy, maxR);
grad.addColorStop(0, 'rgba(255,255,255,1)'); grad.addColorStop(0, 'rgba(255,255,255,1)');
grad.addColorStop(0.5, 'rgba(255,255,255,0.65)'); grad.addColorStop(0.4, 'rgba(255,255,255,0.8)');
grad.addColorStop(1, 'rgba(255,255,255,0)'); grad.addColorStop(1, 'rgba(255,255,255,0)');
lightCtx.fillStyle = grad; lightCtx.fillStyle = grad;
// Рисуем shape по dists (звездоподобный полигон) // Рисуем shape по dists (звездоподобный полигон)
@ -3694,10 +3694,10 @@ function customConfirm(msg, onYes) {
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.7 + Math.sin(now/90 + b.gx*3.7)*0.15 + Math.sin(now/140 + b.gy*2.3)*0.15;
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.6 * flick; const r = def.lightRadius * 0.75 * flick;
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.12*flick})`); grad.addColorStop(0, `rgba(255,180,80,${0.22*flick})`);
grad.addColorStop(0.5, `rgba(255,140,40,${0.06*flick})`); grad.addColorStop(0.5, `rgba(255,140,40,${0.10*flick})`);
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

@ -92,6 +92,6 @@
</div> </div>
</div> </div>
<script src="game.js?v=15"></script> <script src="game.js?v=16"></script>
</body> </body>
</html> </html>