From 14849101dd651a02088dcc084d5ea34892e42084 Mon Sep 17 00:00:00 2001 From: Kistaro Windrider Date: Sat, 28 Jun 2025 22:48:32 -0700 Subject: [PATCH] skip call to sparks if there are no sparks Then don't check for nil spark colors in sparks itself. Also uses a more verbose but more efficient exit check, and fixes a bug. --- vacuum_gambit.p8 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vacuum_gambit.p8 b/vacuum_gambit.p8 index 769bf46..7ac22b0 100644 --- a/vacuum_gambit.p8 +++ b/vacuum_gambit.p8 @@ -539,7 +539,7 @@ function ship_m:move() if (self.dead) return; self:refresh_shield() local dx, dy, shoot_spec1, shoot_spec2 = self:act() - local sg, xm, ym = self.special_guns, self.xmomentum, self.ymomentum + local sg, xm, ym, sp = self.special_guns, self.xmomentum, self.ymomentum, self.sparks dx = self:constrain(self.x, xm, self.xmin, self.xmax, dx) dy = self:constrain(self.y, ym, self.ymin, self.ymax, dy) self:maybe_shoot(self.main_gun) @@ -547,7 +547,7 @@ function ship_m:move() if (shoot_spec1) self:maybe_shoot(sg[1]) if (shoot_spec2) self:maybe_shoot(sg[2]) end - spark(self.sparks, self.x + 4*self.size, self.y + 4*self.size, dx*2.5, dy*2.5, self.sparkodds) + if(sp) spark(sp, self.x + 4*self.size, self.y + 4*self.size, dx*2.5, dy*2.5, self.sparkodds) xm = self:calc_velocity(xm, dx) ym = self:calc_velocity(ym, dy) @@ -1637,7 +1637,7 @@ function spark_particle:draw() end function spark(sprs, x, y, dx, dy, odds, fg) - if (sprs==nil or flr(rnd(odds) or (abs(dx) < 0.5 and abs(dy))) ~= 0) return + if ((dx > -0.5 and dx < 0.5 and dy > -0.5 and dy < 0.5) or rnd(odds) >= 1) return local target = fg and intangibles_fg or intangibles_bg target[#target+1] = spark_particle.new{ x = x + rnd(4) - 2,