Skip to content

Commit

Permalink
Widescreenify submap snow (closes #1779)
Browse files Browse the repository at this point in the history
  • Loading branch information
LordMonoxide committed Dec 6, 2024
1 parent 36f5d2a commit 505bd2a
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/main/java/legend/game/submap/SnowEffect.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class SnowEffect {
private int snowEffectTick;
private int snowOffsetXTick;
private final SnowParticleData18 particleData;
private final SnowParticleInstance3c[] particles = new SnowParticleInstance3c[256];
private final SnowParticleInstance3c[] particles;

public MeshObj particle;
public final MV transforms = new MV();
Expand Down Expand Up @@ -67,7 +67,10 @@ private static class SnowParticleInstance3c {
}

public SnowEffect(final float stepAngleMax, final int translationScaleX, final int stepXMax, final int stepYDivisor) {
final float displayWidthModifier = RENDERER.getRenderAspectRatio() / RENDERER.getNativeAspectRatio();

this.particleData = new SnowParticleData18(stepAngleMax, translationScaleX, stepXMax, stepYDivisor);
this.particles = new SnowParticleInstance3c[(int)(256 * displayWidthModifier)];
}

public void initSnowEffect() {
Expand Down Expand Up @@ -139,6 +142,8 @@ public void initSnowEffect() {
}

public void render() {
final float displayWidthModifier = RENDERER.getRenderAspectRatio() / RENDERER.getNativeAspectRatio();

//LAB_800ee38c
for(int i = 0; i < this.particles.length; i++) {
final SnowParticleInstance3c inst = this.particles[i];
Expand All @@ -148,14 +153,14 @@ public void render() {
inst.xAccumulator_24 += inst.stepX_1c / (2.0f / vsyncMode_8007a3b8);
inst.x_16 = inst.xAccumulator_24 + ((inst.translationScaleX_10 * sin(inst.angle_08) / (MathHelper.TWO_PI)) / (2.0f / vsyncMode_8007a3b8));

if(inst.x_16 < -200.0f) {
inst.x_16 = 200.0f;
inst.xAccumulator_24 = 200.0f;
if(inst.x_16 < -200.0f * displayWidthModifier) {
inst.x_16 = 200.0f * displayWidthModifier;
inst.xAccumulator_24 = 200.0f * displayWidthModifier;
inst.angle_08 = 0.0f;
//LAB_800ee42c
} else if(inst.x_16 > 200.0f) {
inst.x_16 = -200.0f;
inst.xAccumulator_24 = -200.0f;
} else if(inst.x_16 > 200.0f * displayWidthModifier) {
inst.x_16 = -200.0f * displayWidthModifier;
inst.xAccumulator_24 = -200.0f * displayWidthModifier;
inst.angle_08 = 0.0f;
}

Expand All @@ -170,16 +175,16 @@ public void render() {
inst.angle_08 = (inst.angle_08 + inst.angleStep_0c / (2.0f / vsyncMode_8007a3b8)) % MathHelper.TWO_PI;
} else {
//LAB_800ee52c
this.wrapAroundSnowEffect(inst);
this.wrapAroundSnowEffect(inst, displayWidthModifier);
}
//LAB_800ee534
}
//LAB_800ee544
}

/** Reuse snow effect when it reaches the bottom of the screen */
private void wrapAroundSnowEffect(final SnowParticleInstance3c inst) {
inst.x_16 = this.rand.nextFloat(400.0f) - 200.0f + this.snowOffsetXTick;
private void wrapAroundSnowEffect(final SnowParticleInstance3c inst, final float displayWidthModifier) {
inst.x_16 = this.rand.nextFloat(400.0f * displayWidthModifier) - 200.0f * displayWidthModifier + this.snowOffsetXTick;
inst.y_18 = -128.0f;

final int stepXMax = this.particleData.stepXMax_10;
Expand Down

0 comments on commit 505bd2a

Please sign in to comment.