Skip to content

Commit

Permalink
Wind look beautiful
Browse files Browse the repository at this point in the history
  • Loading branch information
Nhawdge committed Nov 7, 2023
1 parent 28962d3 commit 3a708e5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions Components/Effect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ internal class Effect
public bool CreateTrail = false;

public bool Wiggle = false;
public float WiggleTimerOffset = 0f;

public float FadeStart = 1f;
}
Expand Down
4 changes: 4 additions & 0 deletions Entities/Archetypes/EffectsBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ internal static void CreateAirTrail(World world, Vector2 pos, Vector2 motion, bo
effect.FadeStart = 0.4f;
effect.CreateTrail = createTrail;
effect.Duration = (createTrail ? 5f : 1f) * 3;
if (createTrail)
{
effect.WiggleTimerOffset = (float)Random.Shared.Next(0,2) ;
}
effect.Motion = motion;
effectEntity.Set(effect);

Expand Down
2 changes: 1 addition & 1 deletion Scenes/Levels/Systems/EffectsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ internal override void Update(World world)
var truePosition = effect.TruePosition;
var direction = (float)Math.Atan2(effect.Motion.Y, effect.Motion.X);

var offset = new Vector2((float)Math.Sin(effect.Elapsed) * 100, 0);
var offset = new Vector2(0, (float)Math.Sin(effect.Elapsed + effect.WiggleTimerOffset) * 50);
var rotatedOffset = RayMath.Vector2Rotate(offset, direction);

sprite.Position = truePosition + rotatedOffset;
Expand Down

0 comments on commit 3a708e5

Please sign in to comment.