From 2b02d2b94b1f19d0dc8fc8701ed847f5c4077f1f Mon Sep 17 00:00:00 2001 From: Kistaro Windrider Date: Sat, 30 Sep 2023 12:52:58 -0700 Subject: [PATCH] fix blast projectile for rearranged checks --- updatedshmup.p8 | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/updatedshmup.p8 b/updatedshmup.p8 index 303ceb4..334c2f8 100644 --- a/updatedshmup.p8 +++ b/updatedshmup.p8 @@ -1166,20 +1166,31 @@ blast = { damage = 4, dx = 0, -- px/frame dy = 2, + awaitcancel = false, -- disable damage for 2 frames -- when hitting something hitship = function(self, _) - self.damage = 0 - local wait = 2 - events:push_back{move=function() - wait -= 1 - if wait <= 0 then - self.damage = 4 + if self.damage > 0 and not self.awaitcancel then + self.awaitcancel = true + events:push_back{move = function() + new_events:push_back{ + wait = 2, + obj = self, + saved_dmg = self.damage, + move = function(self) + self.wait -= 1 + if self.wait <= 0 then + self.obj.damage = self.saved_dmg + return true + end + end, + } + self.damage = 0 + self.awaitcancel = false return true - end - return false - end} + end} + end end } blast_t = {