-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbubbles.lua
More file actions
48 lines (33 loc) · 1.3 KB
/
bubbles.lua
File metadata and controls
48 lines (33 loc) · 1.3 KB
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
-- defining module parameters
local module = createModule()
module.params.indexNG = 3
module.params.lifeTime = 90
module.params.radiusMin = 768
module.params.radiusMax = 1024
-- defing the group and init functions
local bubbles
local function bubbleInit()
local part = createSpritePart(bubbles) -- create a particle of the "bubbles" group
part.emitterIndex = getTombIndex(module.params.indexNG) -- get Tomb index of moveable
part.lifeSpan = module.params.lifeTime
part.sizeStart = randomInt(32, 128)
part.sizeEnd = part.sizeStart
part.colStart.r = 64
part.colStart.g = randomInt(200, 255)
part.colStart.b = randomInt(200, 255)
part.colEnd = part.colStart
-- circular spawning formation
local ang = degToRad(randomInt(0, 359)) -- get random angle between 0 and 359 degrees, convert to radians
local r = randomFloat(768, 1024) -- circle radius
local cx = r * cos(ang)
local cy = r * sin(ang)
part.pos.x = cx
part.pos.y = randomFloat(-512, 512)
part.pos.z = cy
-- upwards velocity depends on size of bubble (bigger is faster)
part.vel.y = -part.sizeStart * 0.25
part.spriteIndex = 13 -- "bubble" sprite texture
part.fadeIn = 30 -- fade in for 1 second
part.fadeOut = 30 -- fade out for 1 second
end
bubbles = createGroup(bubbleInit, nil)