Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public WorldPosition PositionAt(float elapsed)
- {
- float periodFactor = 0;
- float amplitudeFactor = 0;
- float theta = 0;
- float t = 0;
- float x = 0;
- float y = 0;
- float sin = 0;
- float cos = 0;
- float halfway = 0;
- float deflection = 0;
- WorldPosition p = new WorldPosition(StartPos.X, StartPos.Y);
- float dist = elapsed * ((float)Desc.Speed / 10000.0f);
- float phase = BulletId % 2 == 0 ? 0 : (float)Math.PI;
- if (Desc.Wavy)
- {
- periodFactor = 6 * (float)Math.PI;
- amplitudeFactor = (float)Math.PI / 64.0f;
- theta = Angle + amplitudeFactor * (float)Math.Sin(phase + periodFactor * (float)elapsed / 1000.0f);
- p.X = p.X + dist * (float)Math.Cos(theta);
- p.Y = p.Y + dist * (float)Math.Sin(theta);
- }
- else if (Desc.Parametric)
- {
- t = (float)elapsed / LifetimeMS * 2 * (float)Math.PI;
- x = (float)Math.Sin(t) * (BulletId % 2 == 1 ? 1 : -1);
- y = (float)Math.Sin(2 * t) * (BulletId % 4 < 2 ? 1 : -1);
- sin = (float)Math.Sin(Angle);
- cos = (float)Math.Cos(Angle);
- p.X = p.X + (((x * cos) - (y * sin)) * Desc.Magnitude);
- p.Y = p.Y + (((x * sin) + (y * cos)) * Desc.Magnitude);
- }
- else
- {
- if (Desc.Boomerang)
- {
- halfway = LifetimeMS * (Desc.Speed / 10000) / 2;
- if (dist > halfway)
- {
- dist = halfway - (dist - halfway);
- }
- }
- p.X = p.X + dist * (float)Math.Cos(Angle);
- p.Y = p.Y + dist * (float)Math.Sin(Angle);
- if (Desc.Amplitude != 0)
- {
- deflection = Desc.Amplitude * (float)Math.Sin(phase + (float)elapsed / LifetimeMS * Desc.Frequency * 2 * (float)Math.PI);
- p.X = p.X + deflection * (float)Math.Cos(Angle + (float)Math.PI / 2);
- p.Y = p.Y + deflection * (float)Math.Sin(Angle + (float)Math.PI / 2);
- }
- }
- return p;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement