1{
2   "MaxCount": 300,
3   "Drawable": {
4      "Type": "SkCircleDrawable",
5      "Radius": 3
6   },
7   "Code": [
8      "void effectSpawn(inout Effect effect) {",
9      "  // Phase one: Launch",
10      "  effect.lifetime = 4;",
11      "  effect.rate = 120;",
12      "  float a = radians(mix(-20, 20, rand(effect.seed)) - 90);",
13      "  float s = mix(200, 220, rand(effect.seed));",
14      "  effect.vel.x = cos(a) * s;",
15      "  effect.vel.y = sin(a) * s;",
16      "  effect.color.rgb = float3(rand(effect.seed), rand(effect.seed), rand(effect.seed));",
17      "  effect.pos.x = 0;",
18      "  effect.pos.y = 0;",
19      "  effect.scale = 0.25;  // Also used as particle behavior flag",
20      "}",
21      "",
22      "void effectUpdate(inout Effect effect) {",
23      "  if (effect.age > 0.5 && effect.rate > 0) {",
24      "    // Phase two: Explode",
25      "    effect.rate = 0;",
26      "    effect.burst = 50;",
27      "    effect.scale = 1;",
28      "  } else {",
29      "    effect.vel.y += dt * 90;",
30      "  }",
31      "}",
32      "",
33      "void spawn(inout Particle p) {",
34      "  bool explode = p.scale == 1;",
35      "",
36      "  p.lifetime = explode ? (2 + rand(p.seed) * 0.5) : 0.5;",
37      "  float a = radians(rand(p.seed) * 360);",
38      "  float s = explode ? mix(90, 100, rand(p.seed)) : mix(5, 10, rand(p.seed));",
39      "  p.vel.x = cos(a) * s;",
40      "  p.vel.y = sin(a) * s;",
41      "}",
42      "",
43      "void update(inout Particle p) {",
44      "  p.color.a = 1 - p.age;",
45      "  if (p.scale == 1) {",
46      "    p.vel.y += dt * 50;",
47      "  }",
48      "}",
49      ""
50   ],
51   "Bindings": []
52}