Skip to content

Commit

Permalink
horizontal sine for hires snow
Browse files Browse the repository at this point in the history
  • Loading branch information
earthwise01 committed Jan 14, 2025
1 parent be2b4a0 commit 26b3fbb
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Loenn/effects/parallax_hires_snow.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ effect.defaultData = {
minSpeed = 2000, maxSpeed = 4000,
minScrollX = 1, minScrollY = 1,
maxScrollX = 1.25, maxScrollY = 1.25,
sineAmplitude = 100, sineFrequency = 10,
sineAmplitude = 100, sineFrequency = 10, sineHorizontal = false,
particleCount = 50, speedStretching = true

}
Expand All @@ -26,7 +26,7 @@ effect.fieldOrder = {
"minScrollX", "minScrollY", "directionX", "directionY",
"maxScrollX", "maxScrollY", "minSpeed", "maxSpeed",
"sineAmplitude", "sineFrequency", "minScale", "maxScale",
"randomRotation", "speedStretching", "fadeTowardsForeground", "fadeInOut"
"randomRotation", "speedStretching", "sineHorizontal", "fadeTowardsForeground", "fadeInOut"
}

effect.fieldInformation = {
Expand Down
1 change: 1 addition & 0 deletions Loenn/lang/en_gb.lang
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ style.effects.SorbetHelper/ParallaxHiResSnow.description.maxScrollX=Determines t
style.effects.SorbetHelper/ParallaxHiResSnow.description.maxScrollY=Determines the amount of vertical parallax the closest particles should have.
style.effects.SorbetHelper/ParallaxHiResSnow.description.sineAmplitude=How tall the sine movement of the particles is.
style.effects.SorbetHelper/ParallaxHiResSnow.description.sineFrequency=How fast the sine movement of the particles is.
style.effects.SorbetHelper/ParallaxHiResSnow.description.sineHorizontal=Determines whether the sine movement of the particles is horizontal or vertical.
style.effects.SorbetHelper/ParallaxHiResSnow.description.particleCount=The number of particles the effect should have.
style.effects.SorbetHelper/ParallaxHiResSnow.attribute.fadeInOut=Fade In/Out
style.effects.SorbetHelper/ParallaxHiResSnow.description.fadeInOut=Whether the effect should fade in/out when changing visibility (e.g. when transitioning to a different room or toggling its flag).
Expand Down
2 changes: 2 additions & 0 deletions Loenn/lang/en_gb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,8 @@ Effects:
Description: How tall the sine movement of the particles is.
sineFrequency:
Description: How fast the sine movement of the particles is.
sineHorizontal:
Description: Determines whether the sine movement of the particles is horizontal or vertical.
particleCount:
Description: The number of particles the effect should have.
fadeInOut:
Expand Down
7 changes: 6 additions & 1 deletion Source/Backdrops/ParallaxHiResSnow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public void Reset(Vector2 direction, ParallaxHiResSnow backdrop) {
private readonly float MinSpeed, MaxSpeed;
private readonly Vector2 MinScroll, MaxScroll;
private readonly float SineAmplitude, SineFrequency;
private readonly bool SineHorizontal;
private readonly bool RandomTextureRotation;
private readonly bool SpeedStretching;
private readonly bool FadeTowardsForeground;
Expand Down Expand Up @@ -91,6 +92,7 @@ public ParallaxHiResSnow(BinaryPacker.Element data) : base() {
MaxScroll.Y = data.AttrFloat("maxScrollY", 1.25f);
SineAmplitude = data.AttrFloat("sineAmplitude", 100f);
SineFrequency = data.AttrFloat("sineFrequency", 10f) / 10f;
SineHorizontal = data.AttrBool("sineHorizontal", false);

var texturePath = data.Attr("texturePath", "snow");
particleTexture = OVR.Atlas.GetOrDefault(texturePath, OVR.Atlas["snow"]);
Expand Down Expand Up @@ -130,7 +132,10 @@ public override void Update(Scene scene) {
ref var particle = ref particles[i];

particle.Position += Direction * particle.Speed * Engine.DeltaTime;
particle.Position.Y += (float)Math.Sin(particle.Sin) * SineAmplitude * Engine.DeltaTime;
if (!SineHorizontal)
particle.Position.Y += (float)Math.Sin(particle.Sin) * SineAmplitude * Engine.DeltaTime;
else
particle.Position.X += (float)Math.Sin(particle.Sin) * SineAmplitude * Engine.DeltaTime;
particle.Sin += Engine.DeltaTime * SineFrequency;

// if (particle.RenderPosition.X < -EdgePaddingAmount || particle.RenderPosition.X > (1920 + EdgePaddingAmount) || particle.RenderPosition.Y < -EdgePaddingAmount || particle.RenderPosition.Y > (1080 + EdgePaddingAmount)) {
Expand Down

0 comments on commit 26b3fbb

Please sign in to comment.