private void updateParticle2(float step_time, Particle p, cWorld world) { p.Vel.Y += (Constants.GRAVITY * 40.0f * (step_time * step_time)); // p.Vel.X *= p.SlowDown; // p.Vel.Y *= p.SlowDown; AppMath.Vec2Truncate(ref p.Vel, p.MaxSpeed); //world.collideParticleSAT(p, step_time, false); //p.Heading = cAppMath.Vec2NormalizeReturn(p.Vel); p.LastPos = p.Pos; p.Pos.X += p.Vel.X * step_time; p.Pos.Y += p.Vel.Y * step_time; if (!AppMath.Vec2IsZero(p.Vel)) { p.Heading = AppMath.Vec2NormalizeReturn(p.Vel); p.Rotation = (float)AppMath.GetAngleOfVector(p.Heading); } world.collideParticleRayTrace(p, step_time); p.Opacity -= p.Fade * step_time; }
public override void Update(float step_time) { cWorld world = particleManager.Scene.World; for (int i = 0; i < pool.CountActive; ++i) { Particle p = pool.get(i); if (!p.Intersects) { /* * p.Dims.Y += p.ScaleSpeed * step_time; //+= * p.Dims.y += p.ScaleSpeed * step_time; //+= */ cAppMath.Vec2Truncate(ref p.Vel, p.MaxSpeed * 1.5f); p.Vel.Y += (Constants.GRAVITY * 40.0f * (step_time * step_time)); p.Vel.X *= p.SlowDown; p.Vel.Y *= p.SlowDown; //p.Heading = cAppMath.Vec2NormalizeReturn(p.Vel); p.LastPos = p.Pos; p.Pos.X += p.Vel.X * step_time; p.Pos.Y += p.Vel.Y * step_time; if (!cAppMath.Vec2IsZero(p.Vel)) { p.Heading = cAppMath.Vec2NormalizeReturn(p.Vel); p.Rotation = (float)cAppMath.GetAngleOfVector(p.Heading); } world.collideParticleRayTrace(p, step_time); } p.Opacity -= p.Fade * step_time; if (p.Opacity <= 0.0f) { p.Opacity = 0.0f; pool.deactivate(i); } p.Color.A = (byte)p.Opacity; } }
/// <summary> /// Main update protocol. /// </summary> /// <param name="step_time"></param> /// <param name="p"></param> /// <param name="world"></param> private void updateParticle1(float step_time, Particle p, cWorld world) { // Particle's update code comes here. p.Dims.X += p.ScaleSpeed * step_time; //+= p.Dims.Y += p.ScaleSpeed * step_time; //+= if (AppMath.Vec2Length(p.Dims) < 0.5f) { p.Dims.X = 0.0f; p.Dims.Y = 0.0f; } p.Vel.Y += (Constants.GRAVITY * 40.0f * (step_time * step_time)); p.Vel.X *= p.SlowDown; p.Vel.Y *= p.SlowDown; AppMath.Vec2Truncate(ref p.Vel, p.MaxSpeed * 1.5f); // world.collideParticleSAT(p, step_time, false); //p.Heading = cAppMath.Vec2NormalizeReturn(p.Vel); p.LastPos = p.Pos; p.Pos.X += p.Vel.X * step_time; p.Pos.Y += p.Vel.Y * step_time; if (!AppMath.Vec2IsZero(p.Vel)) { p.Heading = AppMath.Vec2NormalizeReturn(p.Vel); p.Rotation = (float)AppMath.GetAngleOfVector(p.Heading); } world.collideParticleRayTrace(p, step_time); p.Opacity -= p.Fade * step_time; }
public override void Update(float step_time) { cWorld world = particleManager.Scene.World; /* * if(emiting && this.emitTimer.isReady()) * { * // initParticle(); * remaining -= 1; * emiting = remaining > 0; * } */ for (int i = 0; i < pool.CountActive; ++i) { Particle p = pool.get(i); // p.Vel.Y += (Constants.GRAVITY*30 * (step_time * step_time)); p.Vel.X *= p.SlowDown; p.Vel.Y *= p.SlowDown; AppMath.Vec2Truncate(ref p.Vel, p.MaxSpeed); //world.collideParticleSAT(p, step_time); //p.Heading = cAppMath.Vec2NormalizeReturn(p.Vel); Vector2u uSize = this.renderStates.Texture.Size; p.Scale -= p.ScaleSpeed * step_time; p.Dims = new Vector2f(uSize.X * p.Scale, uSize.Y * p.Scale); p.LastPos = p.Pos; p.Pos.X += p.Vel.X * step_time; p.Pos.Y += p.Vel.Y * step_time; if (!AppMath.Vec2IsZero(p.Vel)) { p.Heading = AppMath.Vec2NormalizeReturn(p.Vel); // p.Rotation = (float)cAppMath.GetAngleOfVector(p.Heading); } world.collideParticleRayTrace(p, step_time, true, false); p.Opacity -= p.Fade * step_time; if (p.Opacity <= 0.0f || p.Scale <= 0.0f) { p.Opacity = 0.0f; p.Scale = 0.0f; p.Life -= 1.0f; if (p.Life <= 0.0f) { pool.deactivate(i); } else { this.reinit(p); } } p.Color.A = (byte)p.Opacity; } }