Example #1
0
        // Emit particles
        public void Emit()
        {
            // Emit the right amount
            for (int i = 0; i < EmitAmount; i++)
            {
                // Create ransom stuff
                Random r = new Random();

                // Create the particle
                Particle p = new Particle(this);

                // initialize stuff
                p.Texture        = textures[r.Next(0, textures.Count)];
                p.Position       = Position + new Vector2(MyMaths.RandomInRange(-EmitOffset.X, EmitOffset.X), MyMaths.RandomInRange(-EmitOffset.Y, EmitOffset.Y));
                p.Velocity.X     = MyMaths.RandomInRange(MinStartVelocity.X, MaxStartVelocity.X);
                p.Velocity.Y     = MyMaths.RandomInRange(MinStartVelocity.Y, MaxStartVelocity.Y);
                p.Acceleration.X = MyMaths.RandomInRange(MinAcceleration.X, MaxAcceleration.X);
                p.Acceleration.Y = MyMaths.RandomInRange(MinAcceleration.Y, MaxAcceleration.Y);
                p.Scale.X        = MyMaths.RandomInRange(MinScale.X, MaxScale.X);
                p.Scale.Y        = MyMaths.RandomInRange(MinScale.Y, MaxScale.Y);
                p.LifeSpan       = LifeSpan;

                Particles.Add(p);
            }
        }
Example #2
0
        public override void Draw(SpriteBatch spriteBatch)
        {
            Vector2 thicknessCorrection = new Vector2((thickness / 2) * Math.Sign(speed.Y), (thickness / 2) * -Math.Sign(speed.X));

            ShapeRenderer.DrawLine(spriteBatch, startPosition + thicknessCorrection, Position + speed + thicknessCorrection, Color.Red, thickness, .8f);

            Vector2 random = new Vector2(MyMaths.RandomInRange(-thickness / 4, thickness / 4), MyMaths.RandomInRange(-thickness / 4, thickness / 4));

            ShapeRenderer.DrawLine(spriteBatch, startPosition + random + thicknessCorrection / 3, Position + speed / 2 + random + thicknessCorrection / 3, Color.Pink, thickness / 3, .8f);

            base.Draw(spriteBatch);
        }