From ef40c245f89d858ed4fa32fce395297ef3e14088 Mon Sep 17 00:00:00 2001 From: Kistaro Windrider Date: Sat, 21 Jun 2025 15:12:40 -0700 Subject: [PATCH] multi-step shot prototype nothing reaches this new logic yet, and multiple steps aren't drawn --- vacuum_gambit.p8 | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/vacuum_gambit.p8 b/vacuum_gambit.p8 index a661d66..b970c10 100644 --- a/vacuum_gambit.p8 +++ b/vacuum_gambit.p8 @@ -257,22 +257,30 @@ function updategame() if(es:hitship(ps)) eship_collider:yoink(es) end ebullets:strip(function(eb) - -- loopify this when split moves implemented - if (eb:move()) return true - if (not collides(pbox, hurtbox(eb))) return - ps:hitbullet(eb) - return eb:hitship(ps) + local disposition + repeat + disposition=eb:step() + if collides(pbox, hurtbox(eb)) then + ps:hitbuillet(eb) + if (eb:hitship(ps)) return true + end + until disposition + return disposition == "dead" end) else - ebullets:stripmove() + ebullets:strip(function(eb) repeat until eb:step() end) end pbullets:strip(function(pb) - if (pb:move()) return true - for es in eship_collider:iterate_collisions(hurtbox(pb)) do - if (es:hitbullet(pb)) eship_collider:yoink(es) - if (pb:hitship(es)) return true - end + local disposition + repeat + disposition=pb:step() + for es in eship_collider:iterate_collisions(hurtbox(pb)) do + if (es:hitbullet(pb)) eship_collider:yoink(es) + if (pb:hitship(es)) return true + end + until disposition + return disposition == "dead" end) intangibles_fg:stripmove() @@ -692,9 +700,10 @@ end -- default: die, return true. -- returns whether to delete -- the bullet --- die -- on-removal event, --- default no-op -bullet_base = mknew{ } +bullet_base = mknew{ + steps=1, + current_step=0 +} gun_base = mknew{ shoot_ready = -32768, @@ -820,11 +829,13 @@ function bullet_base:hitship(_) return true end -function bullet_base:move() +function bullet_base:step() + self.current_step=(self.current_step+1)%self.steps self.x += self.dx self.y += self.dy if (self.f) self.f -= 1 - return (self.y > 130) or (self.y < -self.height*8) or (self.f and self.f < 0) or (self.x > 128) or (self.x < -self.width*8) + if ((self.y > 130) or (self.y < -self.height*8) or (self.f and self.f < 0) or (self.x > 128) or (self.x < -self.width*8)) return "dead" + if (self.current_step == 0) return "stop" end function bullet_base:draw()