Particle Effects Demo
This demonstrates how to generate more complex particle effects. The particles animations in TypeScript are extended to create new effects. The some of the effects created are spinning pinwheels, floating bubbles, and falling stars. Pressing button A will add an effect to the display. The effects are combined and displayed together. Pressing button B will remove one of the effects currently shown.
interface ParticleDemonstration {
start(): particles.ParticleSource[];
}
// show controls
let ctlMessage = image.create(scene.screenWidth(), 10);
ctlMessage.printCenter("Effects: 'A' (+), 'B' (-)", 0, 0);
let msgSprite = sprites.create(ctlMessage);
let msgInterval = 0;
const myDemonstrations: ParticleDemonstration[] = [];
let count = 1;
controller.A.onEvent(ControllerButtonEvent.Pressed, function () {
count = Math.min(count + 1, 6);
});
controller.B.onEvent(ControllerButtonEvent.Pressed, function () {
count = Math.max(count - 1, 1);
});
namespace demonstrations {
export class Fire implements ParticleDemonstration {
start() {
const sources: particles.ParticleSource[] = [];
const factory = new particles.FireFactory(8);
const src="/?originalUrl=https%3A%2F%2Farcade.makecode.com%2Fnew%2520particles.FireSource(makeSimpleAnchor()%2C%2520100%2C%2520factory)%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520src.setAcceleration(0%2C%2520-40)%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520sources.push(src)%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520return%2520sources%3B%2520%2520%2520%2520%2520%2520%2520%2520%257D%2520%2520%2520%2520%257D%2520%2520%2520%2520export%2520class%2520Spinner%2520implements%2520ParticleDemonstration%2520%257B%2520%2520%2520%2520%2520%2520%2520%2520start()%2520%257B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520class%2520RingFactory%2520extends%2520particles.RadialFactory%2520%257B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520createParticle(anchor%3A%2520particles.ParticleAnchor)%2520%257B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520const%2520p%2520%3D%2520super.createParticle(anchor)%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520p.lifespan%2520%3D%2520this.galois.randomRange(200%2C%2520350)%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520return%2520p%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%257D%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%257D%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520const%2520sources%3A%2520particles.ParticleSource%5B%5D%2520%3D%2520%5B%5D%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520const%2520colors%2520%3D%2520%5B0x9%2C%25200xA%2C%25200xB%2C%25200xC%5D%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520const%2520factory%2520%3D%2520new%2520RingFactory(20%2C%252030%2C%252010%2C%2520colors)%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520const%2520src%2520%3D%2520new%2520particles.ParticleSource(makeSimpleAnchor()%2C%2520400%2C%2520factory)%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520sources.push(src)%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520return%2520sources%3B%2520%2520%2520%2520%2520%2520%2520%2520%257D%2520%2520%2520%2520%257D%2520%2520%2520%2520export%2520class%2520BubbleConfetti%2520implements%2520ParticleDemonstration%2520%257B%2520%2520%2520%2520%2520%2520%2520%2520start()%2520%257B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520const%2520sources%3A%2520particles.ParticleSource%5B%5D%2520%3D%2520%5B%5D%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520const%2520min%2520%3D%25201000%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520const%2520anchor%2520%3D%2520makeSimpleAnchor()%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520anchor.width%2520%3D%2520screen.width%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520const%2520bubbleFactory%2520%3D%2520new%2520particles.BubbleFactory(anchor%2C%2520min%2C%2520min%2520*%25202.5)%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520sources.push(new%2520particles.BubbleSource(anchor%2C%252030%2C%2520bubbleFactory.stateCount%2520-%25201%2C%2520bubbleFactory))%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520const%2520confettiFactory%2520%3D%2520new%2520particles.ConfettiFactory(anchor.width%2C%252016)%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520confettiFactory.setSpeed(50)%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520sources.push(new%2520particles.ParticleSource(anchor%2C%252050%2C%2520confettiFactory))%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520return%2520sources%3B%2520%2520%2520%2520%2520%2520%2520%2520%257D%2520%2520%2520%2520%257D%2520%2520%2520%2520export%2520class%2520RadialGroup%2520implements%2520ParticleDemonstration%2520%257B%2520%2520%2520%2520%2520%2520%2520%2520start()%2520%257B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520const%2520sources%3A%2520particles.ParticleSource%5B%5D%2520%3D%2520%5B%5D%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520const%2520anchor%2520%3D%2520makeSimpleAnchor()%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520const%2520radius%2520%3D%2520Math.percentChance(50)%2520%3F%25200%2520%3A%252020%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520const%2520increaseRate%2520%3D%2520Math.percentChance(50)%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520control.runInParallel(()%2520%3D%26gt%3B%2520%7B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520for%2520(let%2520i%2520%3D%25200%3B%2520i%2520%26lt%3B%25203%3B%2520%2B%2Bi)%2520%7B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520const%2520colors%2520%3D%2520Math.percentChance(10)%2520%3F%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%5B0xC%2C%25200xD%2C%25200xE%5D%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%3A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520Math.percentChance(50)%2520%3F%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%5B0x6%2C%25200x7%2C%25200x8%2C%25200x9%2C%25200xA%5D%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%3A%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520undefined%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520let%2520factory%3A%2520particles.ParticleFactory%2520%3D%2520new%2520particles.RadialFactory(radius%2C%252090%2C%25205%2C%2520colors)%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520const%2520src%2520%3D%2520new%2520particles.ParticleSource(anchor%2C%2520increaseRate%2520%3F%252050%2520%2B%2520(i%2520*%252050)%2520%3A%2520100%2C%2520factory)%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520sources.push(src)%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520pause(350)%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%7D%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%7D)%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520return%2520sources%3B%2520%2520%2520%2520%2520%2520%2520%2520%7D%2520%2520%2520%2520%7D%2520%2520%2520%2520export%2520class%2520Stars%2520implements%2520ParticleDemonstration%2520%7B%2520%2520%2520%2520%2520%2520%2520%2520start()%2520%7B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520class%2520StarFactory%2520extends%2520particles.ParticleFactory%2520%7B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520protected%2520galois%3A%2520Math.FastRandom%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520protected%2520possibleColors%3A%2520number%5B%5D%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520images%3A%2520Image%5B%5D%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520constructor(possibleColors%3F%3A%2520number%5B%5D)%2520%7B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520super()%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520this.galois%2520%3D%2520new%2520Math.FastRandom()%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520this.images%2520%3D%2520%5B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520img%60%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%25201%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%60%2C%2520img%60%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%25201%2520.%25201%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520.%25201%2520.%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%25201%2520.%25201%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%60%2C%2520img%60%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520.%25201%2520.%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%25201%25201%25201%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520.%25201%2520.%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%60%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%5D%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520if%2520(possibleColors%2520%26amp%3B%26amp%3B%2520possibleColors.length)%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520this.possibleColors%2520%3D%2520possibleColors%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520else%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520this.possibleColors%2520%3D%2520%5B1%5D%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%7D%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520createParticle(anchor%3A%2520particles.ParticleAnchor)%2520%7B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520const%2520p%2520%3D%2520super.createParticle(anchor)%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520p._x%2520%3D%2520Fx8(this.galois.randomRange(0%2C%2520screen.width))%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520p._y%2520%3D%2520Fx8(0)%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520p.vy%2520%3D%2520Fx8(this.galois.randomRange(40%2C%252060))%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2F%2F%2520set%2520lifespan%2520based%2520off%2520velocity%2520and%2520screen%2520height%2520(plus%2520a%2520little%2520to%2520make%2520sure%2520it%2520doesn%26%2339%3Bt%2520disappear%2520early)%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520p.lifespan%2520%3D%2520Fx.toInt(Fx.mul(Fx.div(Fx8(screen.height%2520%2B%252020)%2C%2520p.vy)%2C%2520Fx8(1000)))%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520const%2520length%2520%3D%2520this.possibleColors.length%2520-%25201%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520p.color%2520%3D%2520this.possibleColors%5Bthis.possibleColors.length%2520-%25201%5D%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520for%2520(let%2520i%2520%3D%25200%3B%2520i%2520%26lt%3B%2520length%3B%2520%2B%2Bi)%2520%7B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520if%2520(this.galois.percentChance(50))%2520%7B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520p.color%2520%3D%2520this.possibleColors%5Bi%5D%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520break%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%7D%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%7D%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2F%2F%2520images%2520besides%2520the%2520first%2520one%2520are%2520only%2520used%2520on%2520occasion%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520p.data%2520%3D%2520this.galois.percentChance(15)%2520%3F%2520this.galois.randomRange(1%2C%2520this.images.length%2520-%25201)%2520%3A%25200%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520return%2520p%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%7D%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520drawParticle(p%3A%2520particles.Particle%2C%2520x%3A%2520Fx8%2C%2520y%3A%2520Fx8)%2520%7B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2F%2F%2520on%2520occasion%2C%2520twinkle%2520from%2520white%2520to%2520yellow%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520const%2520twinkleFlag%2520%3D%25200x8000%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520const%2520rest%2520%3D%25200x7FFF%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520if%2520(twinkleFlag%2520%26amp%3B%26amp%3B%2520p.data)%2520%7B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520if%2520(this.galois.percentChance(10))%2520%7B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520p.color%2520%3D%25201%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520p.data%2520%26amp%3B%3D%2520rest%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%7D%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%7D%2520else%2520if%2520(p.color%2520%3D%3D%3D%25201%2520%26amp%3B%26amp%3B%2520this.galois.percentChance(1))%2520%7B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520p.color%2520%3D%25205%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520p.data%2520%7C%3D%2520twinkleFlag%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%7D%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520const%2520selected%2520%3D%2520this.images%5Brest%2520%26amp%3B%2520p.data%5D.clone()%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520selected.replace(0x1%2C%2520p.color)%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520screen.drawImage(selected%2C%2520Fx.toInt(x)%2C%2520Fx.toInt(y))%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%7D%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%7D%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520const%2520sources%3A%2520particles.ParticleSource%5B%5D%2520%3D%2520%5B%5D%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520const%2520colors%2520%3D%2520%5B1%5D%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520for%2520(let%2520i%2520%3D%25200%3B%2520i%2520%26lt%3B%25204%3B%2520i%2B%2B)%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520colors.push(randint(2%2C%25200xE))%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520const%2520factory%2520%3D%2520new%2520StarFactory(colors)%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520const%2520src%2520%3D%2520new%2520particles.ParticleSource(makeSimpleAnchor()%2C%252025%2C%2520factory)%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520sources.push(src)%3B%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520return%2520sources%3B%2520%2520%2520%2520%2520%2520%2520%2520%7D%2520%2520%2520%2520%7D%7Dfunction%2520makeSimpleAnchor()%3A%2520particles.ParticleAnchor%2520%7B%2520%2520%2520%2520return%2520%7B%2520%2520%2520%2520%2520%2520%2520%2520x%3A%2520screen.width%2520%26gt%3B%26gt%3B%25201%2C%2520%2520%2520%2520%2520%2520%2520%2520y%3A%2520screen.height%2520%26gt%3B%26gt%3B%25201%2520%2520%2520%2520%7D%3B%7D%2F%2F%2520Radial%2520group%2520as%2520a%2520lot%2520of%2520different%2520possible%2520configurations%2C%2520so%2520make%2520it%2520twice%2520as%2520likely%2520as%2520othersfor%2520(let%2520i%2520%3D%25200%3B%2520i%2520%26lt%3B%25202%3B%2520i%2B%2B)%2520%7B%2520%2520%2520%2520myDemonstrations.push(new%2520demonstrations.RadialGroup())%3B%7DmyDemonstrations.push(new%2520demonstrations.Stars())%3BmyDemonstrations.push(new%2520demonstrations.BubbleConfetti())%3BmyDemonstrations.push(new%2520demonstrations.Spinner())%3BmyDemonstrations.push(new%2520demonstrations.Fire())%3Bforever(()%2520%3D%26gt%3B%2520%7B%2520%2520%2520%2520particles.disableAll()%2520%2520%2520%2520for%2520(let%2520i%2520%3D%25200%3B%2520i%2520%26lt%3B%2520count%3B%2520%2B%2Bi)%2520%7B%2520%2520%2520%2520%2520%2520%2520%2520Math.pickRandom(myDemonstrations)%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520.start()%3B%2520%2520%2520%2520%7D%2520%2520%2520%2520msgSprite.top%2520%3D%2520scene.screenHeight()%3B%2520%2520%2520%2520msgSprite.top%2520%2B%3D%2520msgInterval%2520%25%25205%2520%3D%3D%25200%2520%3F%2520-10%2520%3A%25200%3B%2520%2520%2520%2520msgInterval%2520%2B%3D%25201%3B%2520%2520%2520%2520pause(3000)%3B%7D)%3B%253C%2Fcode">