protected virtual Particle GenerateNewParticle() { var p = new Particle(0, Entity.Body.Position / 2, 30, this) { Physics = { Velocity = Vector2.UnitY } }; return p; }
protected override Particle GenerateNewParticle() { int index = _rand.Next(0, 3); int ttl = _rand.Next(10, 16); //Rotate the point based on the center of the sprite // p = unrotated point, o = rotation origin //p'x = cos(theta) * (px-ox) - sin(theta) * (py-oy) + ox //p'y = sin(theta) * (px-ox) + cos(theta) * (py-oy) + oy var origin = Entity.Body.Position; var unrotatedposition = new Vector2( Entity.Body.BoundingBox.X, Entity.Body.BoundingBox.Bottom - 10); var angle = Entity.Body.Angle; var position = new Vector2( (float)(Math.Cos(angle) * (unrotatedposition.X - origin.X) - Math.Sin(angle) * (unrotatedposition.Y - origin.Y) + origin.X), (float)(Math.Sin(angle) * (unrotatedposition.X - origin.X) + Math.Cos(angle) * (unrotatedposition.Y - origin.Y) + origin.Y) ); var p = new Particle(index, position, ttl, this); var anglev = (float)_rand.NextDouble() - .5f; p.Physics.Thrust((float)_rand.NextDouble(), angle - anglev); return p; }