-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathparticle.lua
More file actions
32 lines (31 loc) · 745 Bytes
/
particle.lua
File metadata and controls
32 lines (31 loc) · 745 Bytes
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
-- require table/merge
_particle = _{
new = function(this, args)
merge(this,{
vel_x = 0,
vel_y = 0,
x = 0,
y = 0,
size = 3,
decay = .5,
color = 7,
},args)
end,
-- init = function(this) end,
-- destroy = function(this) end,
update = function(this)
-- printh('aaaaa!')
this.x += this.vel_x
this.y += this.vel_y
if rnd() < this.decay then this.size -= .5 end
if this.life then
this.life -= 1
if this.life == 0 then this.parent:del(this) end
end
if this.size < 0 then this.parent:del(this) end
end,
draw = function(this)
if this.size < 1 then pset(this.x,this.y,this.color)
else circfill(this.x,this.y,this.size,this.color) end
end
}