-
Notifications
You must be signed in to change notification settings - Fork 1
/
fx.lua
276 lines (219 loc) · 4.43 KB
/
fx.lua
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
-- BLAST FLOCK source files
-- by TRASEVOL_DOG (https://trasevol.dog/)
require("drawing")
require("maths")
require("table")
require("object")
require("sprite")
function update_skull(s)
s.t=s.t+0.01*dt30f
if s.t>=0.230 then
deregister_object(s)
end
end
function update_scoretxt(s)
s.t=s.t+1*dt30f
if s.t>=48 then
deregister_object(s)
end
end
--function update_dgrpointer(s)
-- s.t=s.t+1*dt30f
--
-- if s.t>=64 then
-- deregister_object(s)
-- end
--end
function update_screenglitch(s)
s.t = s.t - delta_time
if s.t<=0 then
if rnd(30)<1 then
s.x=s.x+rnd(64)-32
s.y=s.y+rnd(64)-32
s.c=8+flr(rnd(8))
end
if rnd(10)<1 then
s.x=s.ox
s.y=s.oy
end
delta_time = 0.033
end
s.w=s.w+2*dt30f
s.h=s.h-6*dt30f
if s.h<0 or s.w<0 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,-1,0.1*dt30f)
s.r=s.r-0.05*dt30f
if s.r<0 then
deregister_object(s)
end
end
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 draw_skull(s)
draw_anim(s.x,s.y,"skull",nil,s.t)
end
function draw_scoretxt(s)
local c = s.c
local k=abs(flr(s.t/6)-5)
local ca, cb = lighter(c, k), lighter(c, k-1)
font("small")
draw_text(s.txt,s.x,s.y-s.t,1, 25,ca, cb)
end
--function draw_dgrpointer(s) -- not displayed atm
-- if s.t%4>0 then return end
--
-- local scrnw,scrnh=screen_size()
-- local x=clamp(s.x,xmod+16,xmod+scrnw-16)
-- local y=clamp(s.y,ymod+16,ymod+scrnh-16)
--
-- font("pico2")
-- draw_text("!",x,y,1,0,8,2)
--end
function draw_explosion(s)
local c=({25,25,21,21,21,21,21,s.c,s.c})[flr(s.p+dt30f)]
local r=s.r+max(s.p-2,0)
local foo
if s.p<7 then foo=circfill
else foo=circ end
foo(s.x,s.y,r,c)
if s.p==1 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
s.p=s.p+1
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_skull(x,y)
if server_only then return end
local s={
x=x,
y=y,
t=0,
update=update_skull,
draw=draw_skull,
regs={"to_update","to_draw4"}
}
register_object(s)
end
function create_scoretxt(x,y,amount,c)
if server_only then return end
local s={
x=x,
y=y,
txt="+"..amount,
t=t,
c=c,
update=update_scoretxt,
draw=draw_scoretxt,
regs={"to_update","to_draw3"}
}
register_object(s)
return s
end
--function create_dgrpointer(x,y)
-- local s={
-- x=x,
-- y=y,
-- t=0,
-- update=update_dgrpointer,
-- draw=draw_dgrpointer,
-- regs={"to_update","to_draw3"}
-- }
--
-- register_object(s)
--
-- return s
--end
function create_screenglitch(w,h)
if server_only then return end
local scrnw,scrnh=screen_size()
local s={
x=xmod+rnd(scrnw),
y=ymod+rnd(scrnh),
w=0.75*w+rnd(0.5*w),
h=0.75*h+rnd(0.5*h),
c=8,
t=0,
update=update_screenglitch,
regs={"to_update","screen_glitch"}
}
s.ox=s.x
s.oy=s.y
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 1+rnd(3),
c=c or 22,
update=update_smoke,
draw=draw_smoke,
regs={"to_update","to_draw1"}
}
if rnd(2)<1 then s.c=drk[s.c] end
register_object(s)
return s
end