1{
2	"animation": [
3		{
4			"duration": 50,
5			"frames": 1,
6			"frames_per_row": 1,
7			"id": "normal",
8			"image": "tiles/village/human4.png",
9			"pad": 0,
10			"rect": [0,0,71,71],
11            "scale": 1,
12		}
13	],
14	"editor_info": {
15		category: "village"
16	},
17	"hitpoints": 1,
18	"id": "cottage",
19	"mass": 1000,
20	"on_end_anim": "set(animation, 'normal')",
21
22    "consts": {
23        "NUM_PARTICLES": 30,
24		"PARTICLE_LIFETIME": 3.0,
25    },
26
27	"shader": {
28		"program": "inline_test",
29		"draw": "[set(uniforms.u_mvp_matrix, mvp_matrix),set(uniforms.u_color, color)]",
30		"create": "set(uniforms.u_tex_map, 0)",
31	},
32
33    "effects": [
34		{
35			"program": "particle1",
36			"zorder": 1,
37
38			"create": "[
39				set(vars.texture, load_texture('images/smoke.png')),
40				set(uniforms.s_texture, 0),
41				set(uniforms.u_time, 0),
42				set(uniforms.u_centerPosition, [parent.x + 60, parent.y + 3, 0.0]),
43				set(uniforms.u_color, [(1d10001+9999)/20000.0]*3+[0.5]),
44				set(uniforms.u_lifetime, parent.consts.PARTICLE_LIFETIME),
45
46				set(vars.a_startPosition, float_array(flatten(map(range(parent.consts.NUM_PARTICLES), [0.0,0.0])), 2)),
47				set(vars.a_endPosition, float_array(flatten(map(range(parent.consts.NUM_PARTICLES), [(1d2001-1001)/50.0, 1d20-70.0])), 2)),
48				set(vars.a_start_time, float_array(map(range(parent.consts.NUM_PARTICLES), value*(parent.consts.PARTICLE_LIFETIME/parent.consts.NUM_PARTICLES)))),
49
50				set(vars.particle_count, parent.consts.NUM_PARTICLES),
51			]",
52			"draw": [
53				"set_vars",
54				"do_draw",
55			],
56
57			"set_vars": "[
58				set(uniforms.u_mvp_matrix, mvp_matrix),
59
60				if(uniforms.u_time >= parent.consts.PARTICLE_LIFETIME,
61					set(uniforms.u_time, 0.0),
62					add(uniforms.u_time, 0.02)),
63
64				bind_texture(vars.texture.id),
65				blend_mode('src_alpha', 'one'),
66
67				set(attributes.a_startPosition, vars.a_startPosition),
68				set(attributes.a_endPosition, vars.a_endPosition),
69				set(attributes.a_start_time, vars.a_start_time),
70			]",
71			"do_draw": "draw_arrays('points', 0, vars.particle_count)",
72		},
73	],
74}
75