File: snake.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 (46 lines) | stat: -rw-r--r-- 926 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
-- vim:syntax=lua tabstop=4

load("functions.lua")

function describe()
    log("Random shaped string of particles")
end
	
function spawn()

	curveness = randomfloat(0, 0.5)
	speed = randomfloat(0,1)
	if (randomint(0,1) == 0) then
		massincrement = randomfloat(-0.01,0.01)
	else
		massincrement = 0
	end
		
	massrandom = randomfloat(0,100)

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

	for i=0,spawnparticles-1 do
	
		pos.x = pos.x + math.cos(ang1)
		pos.y = pos.y + math.sin(ang1)
		pos.y = pos.y + math.cos(ang2)
		pos.z = pos.z + math.sin(ang2)
		
		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 + randomfloat(-curveness,curveness)
		ang2 = ang2 + randomfloat(-curveness,curveness)
		
		particle(i, pos, vel, randomfloat(0,massrandom) + massincrement * i)
	
	end

end