skia2/resources/particles/explosion.json
Brian Osman 8a97782956 Move common particle code to an automatically-injected header
Change-Id: If99e1802c8187ebd98b67717d744c6695bb25900
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/238118
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2019-08-29 18:49:33 +00:00

36 lines
806 B
JSON

{
"MaxCount": 32,
"Duration": 1,
"Rate": 8,
"Drawable": {
"Type": "SkImageDrawable",
"Path": "resources/images/explosion_sprites.png",
"Columns": 4,
"Rows": 4
},
"Code": [
"// float rand; Every read returns a random float [0 .. 1)",
"",
"float2 circle() {",
" float x;",
" float y;",
" do {",
" x = rand * 2 - 1;",
" y = rand * 2 - 1;",
" } while (x*x + y*y > 1);",
" return float2(x, y);",
"}",
"",
"void spawn(inout Particle p) {",
" p.lifetime = 1.0 + rand * 2.0;",
" p.pos = circle() * 60;",
" p.vel = p.pos / 3;",
"}",
"",
"void update(inout Particle p) {",
" p.frame = p.age;",
"}",
""
],
"Bindings": []
}