refactor spark logic. this loses tokens; may need to revisit

This commit is contained in:
Kistaro Windrider 2023-09-30 20:10:42 -07:00
parent a4590821be
commit 2e46d87a84
Signed by: kistaro
SSH Key Fingerprint: SHA256:TBE2ynfmJqsAf0CP6gsflA0q5X5wD5fVKWPsZ7eVUg8

View File

@ -1789,29 +1789,33 @@ function boom(x,y,boominess,is_boss)
return
end
spark_particle={}
function spark_particle:move()
if (rnd(4) < 1) self.sidx += 1
if (self.sidx > #self.sprs) return true
self.x += self.dx
self.y += self.dy
self.dx -= mid(0.05,-0.05, self.dx)
self.dy -= mid(0.05,-0.05, self.dy)
end
function spark_particle:draw()
pset(self.x,self.y,self.sprs[self.sidx])
end
mknew(spark_particle)
function spark(sprs, x, y, butts, thrust, odds, fg)
if (sprs==nil or flr(rnd(odds)) ~= 0) return
thrust *= 2.5
local target = fg and intangibles_fg or intangibles_bg
target:push_back{
target:push_back(spark_particle.new{
x = x + rnd(4) - 2,
y = y + rnd(4) - 2,
sprs = sprs,
sidx = 1,
dx = (butts[0] - butts[1]) * thrust + rnd(2) - 1,
dy = (butts[2] - butts[3]) * thrust + rnd(2) - 1,
draw = function(self)
pset(self.x, self.y, self.sprs[self.sidx])
end,
move = function(self)
if (rnd(4) < 1) self.sidx += 1
if (self.sidx > #self.sprs) return true
self.x += self.dx
self.y += self.dy
self.dx -= mid(0.05,-0.05, self.dx)
self.dy -= mid(0.05,-0.05, self.dy)
end
}
})
end
-->8
-- powerups