File: loops.gravitspawn

package info (click to toggle)
gravit 0.5.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 10,420 kB
  • ctags: 942
  • sloc: ansic: 6,841; makefile: 63; sh: 43
file content (75 lines) | stat: -rw-r--r-- 1,651 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
-- vim:syntax=lua tabstop=4

load("functions.lua")

function describe()

	log("Random looping patterns of particles")

end

function spawn()

	local curveness1 = randomfloat(0, 0.1)
	local curveness2 = randomfloat(0, 0.1)

	local curvechangelimit = 0.0001
	local curvechange1 = 0
	local curvechange2 = 0

	local negativemass = 0
	if (randomint(0,5) == 0) then
		negativemass = 1
	end
	
	if (randomint(0,4) == 0) then
		curvechange1 = randomfloat(-curvechangelimit,curvechangelimit)
	end
	
	if (randomint(0,4) == 0) then
		curvechange2 = randomfloat(-curvechangelimit,curvechangelimit)
	end
	
	local speed = randomfloat(0,5)
	local massincrement = 0

	if (randomint(0,1) == 0) then
		massincrement = randomfloat(-0.01,0.01)
	end
		
	local massrandom = randomfloat(0,100)
	local distance = randomfloat(0.1, 5)

	local pos = v(0,0,0)
	local vel = v(0,0,0)
	local ang1 = 0
	local ang2 = 0

	for i=0,spawnparticles-1 do
	
		pos.x = pos.x + math.cos(ang1) * distance
		pos.y = pos.y + math.sin(ang1) * distance
		pos.y = pos.y + math.cos(ang2) * distance
		pos.z = pos.z + math.sin(ang2) * distance
		
		vel.x = math.cos(ang1) * speed
		vel.y = math.sin(ang1) * speed
		vel.y = math.cos(ang2) * speed
		vel.z = math.sin(ang2) * speed

		ang1 = ang1 + curveness1
		ang2 = ang2 + curveness2

		curveness1 = curveness1 + curvechange1
		curveness2 = curveness2 + curvechange2
	
		if negativemass == 1 then
			particle(i, pos, vel, randomfloat(-massrandom,massrandom) + massincrement * i)
		else
			particle(i, pos, vel, randomfloat(0,massrandom) + massincrement * i)
		end
	
	end

end