Debian Codegraph @

spawn/dust.gravitspawn

raw
1 -- vim:syntax=lua tabstop=4
2
3 load("functions.lua")
4
5 function describe()
6 log("A few massive particles and a ball of relatively ligher particles with random velocities")
7 end
8
9 function spawn()
10
11 local onlyone = randomint(0,1)
12 local massiveparticles
13 local bigrange
14
15 if (onlyone == 1) then
16 massiveparticles = 1
17 bigrange = .1
18 else
19 massiveparticles = randomint(1, 3)
20 bigrange = randomfloat(1, 2)
21 end
22
23 local smallrange = randomfloat(100, 10000)
24 local bigmass = randomfloat(1000, 100000)
25 local smallmass = randomfloat(100, 1000)
26 local smallmassvaries = randomint(0,1)
27 local initvel = randomfloat(1, 100)
28
29 for i=0,spawnparticles-1 do
30
31 if (i < massiveparticles) then
32 pos = randomrange(bigrange)
33 vel = v(0,0,0)
34 mass = bigmass
35 else
36 pos = randomrange(smallrange)
37 vel = randomrange(initvel)
38 if (smallmassvaries == 1) then
39 mass = randomfloat(1,smallmass)
40 else
41 mass = smallmass
42 end
43 end
44
45 particle(i, pos, vel, mass)
46
47 end
48
49 end
50