-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfx.lua
More file actions
183 lines (141 loc) · 3.01 KB
/
Copy pathfx.lua
File metadata and controls
183 lines (141 loc) · 3.01 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
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
-- BLAST FLOCK source files
-- by TRASEVOL_DOG (https://trasevol.dog/)
require("drawing")
require("maths")
require("table")
require("object")
require("sprite")
function add_shake(p)
local a=rnd(1)
shkx=shkx+p*cos(a)
shky=shky+p*sin(a)
end
shkt = 0
function update_shake()
shkt = shkt - love.timer.getDelta()
if shkt < 0 then
if abs(shkx)<0.5 and abs(shky)<0.5 then
shkx,shky=0,0
end
shkx = -(0.5+rnd(0.2))*shkx
shky = -(0.5+rnd(0.2))*shky
shkt = 0.033
end
end
function update_skull(s)
s.t=s.t+0.01*dt30f
if s.t>=0.230 then
deregister_object(s)
end
end
function update_floatingtxt(s)
s.t=s.t+1*dt30f
-- if s.t>=48 then
-- deregister_object(s)
-- end
end
function update_smoke(s)
s.x=s.x+s.vx*dt30f
s.y=s.y+s.vy*dt30f
s.vx=lerp(s.vx, 0,0.1*dt30f)
s.vy=lerp(s.vy,-0.25,0.1*dt30f)
s.r=s.r-0.025*dt30f
if s.r<0 then
deregister_object(s)
end
end
function draw_floatingtxt(s)
local c = s.c
local k=flr(s.t/2)+1
local n=({3,2,1,0,0,0,0,0,1,2,3,4})[k]
if not n then
deregister_object(s)
return
end
local c0, c1, c2 = lighter(c, n-2), lighter(c, n), lighter(c, n+3)
font("small")
draw_text(s.txt,s.x,s.y-s.t, 1, c0, c1, c2)
end
function draw_explosion(s)
local c=({0,0,23,23,23,23,23,s.c,s.c})[flr(s.p)+1]
local r=s.r+max(s.p/4-1,0)
local foo
if s.p<7 then foo=circfill
else foo=circ end
foo(s.x,s.y,r,c)
s.p=s.p+1.5*dt30f
local p = flr(s.p)
if p==1 and s.p%1 < 1.5*dt30f then
if s.r>4 then
for i=0,1 do
local a,l=rnd(1),(0.8+rnd(0.4))*s.r
local x = s.x + l*cos(a)
local y = s.y + l*sin(a)
--local x=s.x+rnd(2.2*s.r)-1.1*s.r
--local y=s.y+rnd(2.2*s.r)-1.1*s.r
local r=0.25*s.r+rnd(0.5*s.r)
create_explosion(x,y,r,s.c)
end
for i=0,2 do
create_smoke(s.x,s.y,1,nil,s.c)
end
end
end
if s.p>=8 then
deregister_object(s)
end
end
function draw_smoke(s)
-- if s.x+s.r<xmod or s.x-s.r>xmod+screen_width or s.y+s.r<ymod or s.y-s.r>ymod+screen_height then
-- return
-- end
circfill(s.x,s.y,s.r,s.c)
end
function create_floatingtxt(x,y,str,c)
if server_only then return end
local s={
x=x,
y=y,
txt=str,
t=0,
c=c,
update=update_floatingtxt,
draw=draw_floatingtxt,
regs={"to_update","to_draw3"}
}
register_object(s)
return s
end
function create_explosion(x,y,r,c)
if server_only then return nil end
local e={
x=x,
y=y,
r=r,
p=0,
c=c,
draw=draw_explosion,
regs={"to_draw3"}
}
register_object(e)
return e
end
function create_smoke(x,y,spd,r,c,a)
if server_only then return nil end
local a=a or rnd(1)
local spd=0.75*spd+rnd(0.5*spd)
local s={
x=x,
y=y,
vx=spd*cos(a),
vy=spd*sin(a),
r=r or rnd(3),
c=c or (-1+irnd(2)),
update=update_smoke,
draw=draw_smoke,
regs={"to_update","to_draw4"}
}
-- if rnd(2)<1 then s.c=drk[s.c] end
register_object(s)
return s
end