private void AddSparks() { float maxRate = 100.0f; float numToGen = maxRate * Time.GameTimeFrameSeconds + leftOvers; int numSparks = (int)numToGen; if (numSparks > kMaxSparks) { numSparks = kMaxSparks; } leftOvers = numToGen - numSparks; Vector3 worldCenter = WorldCenter; Vector3 line = worldCenter + TexW * Radius * (1.0f - 2.0f * Age); float r = (float)Math.Sqrt(Radius * Radius - (line - worldCenter).LengthSquared()); Random rnd = BokuGame.bokuGame.rnd; float speed = 0.5f; for (int i = 0; i < numSparks; ++i) { double ang = rnd.NextDouble() * Math.PI * 2.0; float sing = (float)Math.Sin(ang); float cosg = (float)Math.Cos(ang); _velocities[i] = TexU * cosg + TexV * sing; _positions[i] = line + _velocities[i] * r; _velocities[i] *= speed; } ExplosionManager.CreateSparks(numSparks, _positions, _velocities, 0.05f); }