Aiv.Fast2D.Example.ParticleSystem.ParticleSystem C# (CSharp) Method

ParticleSystem() public method

public ParticleSystem ( float width, float height, int numberOfParticles ) : System
width float
height float
numberOfParticles int
return System
        public ParticleSystem(float width, float height, int numberOfParticles)
        {
            this.random = new Random();
            this.instancedSprite = new InstancedSprite(width, height, numberOfParticles);
            this.particles = new Particle[numberOfParticles];
            for(int i=0;i<numberOfParticles;i++)
            {
                this.particles[i].speed = RandomFloat(30, 60);
                this.particles[i].velocity = new Vector2(RandomFloat(-1, 1), RandomFloat(-1, 0)) * this.particles[i].speed;
                this.particles[i].life = RandomFloat(1, 3);
                this.instancedSprite.SetScale(i, new Vector2(RandomFloat(1, 2), RandomFloat(1, 2)), noUpload: true);
            }
            this.instancedSprite.UpdateScales();
        }