This commit is contained in:
33333-33333 2026-06-21 16:26:12 +09:00
commit 0b9ff1363b
45 changed files with 680 additions and 890 deletions

View file

@ -636,56 +636,38 @@ function drawRain(ctx, w, h, t) {
if (world.weather !== "light_rain") return;
ctx.save();
const perf = world.performanceLevel ? world.performanceLevel() : 0;
const count = perf >= 2 ? 58 : 118;
ctx.lineCap = "round";
const count = perf >= 2 ? 64 : 138;
const angle = -0.32; // Rain visual effect: diagonal streaks, separate from fallen water item sprites.
const slant = Math.tan(angle);
for (let i = 0; i < count; i++) {
const speed = randSeed(18100 + i, 132, 230);
const cycle = h + 320;
const len = randSeed(18500 + i, 13, 26);
const tilt = randSeed(18600 + i, 5, 12);
const fall = randSeed(18400 + i, -220, cycle) + t * speed;
const y = ((fall % cycle) + cycle) % cycle - 140;
// The droplet's movement vector matches the visible diagonal stroke.
const driftPerY = -tilt / Math.max(1, len);
const xCycle = w + 220;
const rawX = randSeed(18000 + i, -70, w + 120) + fall * driftPerY + Math.sin(t * 0.9 + i * 0.43) * 4;
const x = ((rawX % xCycle) + xCycle) % xCycle - 90;
const alpha = y < 110 ? clamp((y + 68) / 178, 0, 1) : 1;
ctx.globalAlpha = 0.34 + 0.30 * alpha;
ctx.strokeStyle = "rgba(196, 200, 202, 0.92)";
ctx.lineWidth = randSeed(18700 + i, 1.0, 1.8);
const speed = randSeed(18100 + i, 360, 620);
const len = randSeed(18500 + i, 14, 28);
const cycleY = h + 260;
const cycleX = w + 260;
const fall = randSeed(18400 + i, -220, cycleY) + t * speed;
const y = ((fall % cycleY) + cycleY) % cycleY - 120;
const drift = fall * slant * 0.42;
const rawX = randSeed(18000 + i, -140, w + 180) + drift;
const x = ((rawX % cycleX) + cycleX) % cycleX - 130;
const alpha = y < 60 ? clamp((y + 90) / 150, 0, 1) : 1;
const dx = Math.sin(angle) * len;
const dy = Math.cos(angle) * len;
ctx.globalAlpha = (0.18 + 0.34 * randSeed(19000 + i, 0.35, 1.0)) * alpha;
ctx.strokeStyle = "rgba(88, 150, 218, 0.86)";
ctx.lineWidth = randSeed(18700 + i, 0.8, 1.45);
ctx.lineCap = "round";
ctx.beginPath();
ctx.moveTo(x, y);
ctx.lineTo(x - tilt, y + len);
ctx.moveTo(x - dx * 0.5, y - dy * 0.5);
ctx.lineTo(x + dx * 0.5, y + dy * 0.5);
ctx.stroke();
if (perf < 3 && i % 2 === 0) {
ctx.globalAlpha = 0.18 + 0.18 * alpha;
ctx.fillStyle = "rgba(213, 216, 218, 0.92)";
if (perf < 3 && i % 4 === 0) {
ctx.globalAlpha = 0.13 * alpha;
ctx.strokeStyle = "rgba(255,255,255,0.70)";
ctx.lineWidth = 0.7;
ctx.beginPath();
ctx.ellipse(x - tilt * 0.9, y + len + 2, 1.8, 3.0, -0.28, 0, Math.PI * 2);
ctx.fill();
}
}
if (perf < 3) {
const dripCount = perf >= 2 ? 10 : 18;
for (let i = 0; i < dripCount; i++) {
const phase = (t * randSeed(18800 + i, 0.55, 1.15) + randSeed(18900 + i, 0, 100)) % 1;
const x = randSeed(19000 + i, 12, w - 12);
const topY = -22 + phase * (h + 58);
const bottomY = topY + randSeed(19100 + i, 14, 30);
const lean = randSeed(19200 + i, -6, -2);
ctx.globalAlpha = 0.44;
ctx.strokeStyle = "rgba(198, 202, 204, 0.98)";
ctx.lineWidth = randSeed(19300 + i, 1.2, 2.2);
ctx.beginPath();
ctx.moveTo(x, topY);
ctx.lineTo(x + lean, bottomY);
ctx.moveTo(x - dx * 0.5 - 1.5, y - dy * 0.5);
ctx.lineTo(x + dx * 0.5 - 1.5, y + dy * 0.5);
ctx.stroke();
ctx.globalAlpha = 0.26;
ctx.beginPath();
ctx.ellipse(x + lean, bottomY + 2, 2.1, 3.5, -0.18, 0, Math.PI * 2);
ctx.fillStyle = "rgba(216, 219, 220, 0.98)";
ctx.fill();
}
}
ctx.restore();
@ -746,7 +728,6 @@ function render() {
const perf = world.performanceLevel ? world.performanceLevel() : 0;
if (perf < 2) drawLightRays(ctx, screenW, screenH, lighting);
if (perf < 3 || world.weather === "light_rain") drawRain(ctx, screenW, screenH, world.time);
const visibleRect = visibleWorldRect(world, 180);
const terrainLayer = ensureTerrainCache(world, lighting);
@ -792,6 +773,7 @@ function render() {
// Light affecting the whole visible scene, including characters and ground.
drawAtmosphericLighting(ctx, screenW, screenH, lighting);
if (world.weather === "light_rain") drawRain(ctx, screenW, screenH, world.time);
const drawAtScreenPosition = (entity, drawFn) => {
if (!entity) return;