multi-step shot prototype
nothing reaches this new logic yet, and multiple steps aren't drawn
This commit is contained in:
@ -257,22 +257,30 @@ function updategame()
|
|||||||
if(es:hitship(ps)) eship_collider:yoink(es)
|
if(es:hitship(ps)) eship_collider:yoink(es)
|
||||||
end
|
end
|
||||||
ebullets:strip(function(eb)
|
ebullets:strip(function(eb)
|
||||||
-- loopify this when split moves implemented
|
local disposition
|
||||||
if (eb:move()) return true
|
repeat
|
||||||
if (not collides(pbox, hurtbox(eb))) return
|
disposition=eb:step()
|
||||||
ps:hitbullet(eb)
|
if collides(pbox, hurtbox(eb)) then
|
||||||
return eb:hitship(ps)
|
ps:hitbuillet(eb)
|
||||||
|
if (eb:hitship(ps)) return true
|
||||||
|
end
|
||||||
|
until disposition
|
||||||
|
return disposition == "dead"
|
||||||
end)
|
end)
|
||||||
else
|
else
|
||||||
ebullets:stripmove()
|
ebullets:strip(function(eb) repeat until eb:step() end)
|
||||||
end
|
end
|
||||||
|
|
||||||
pbullets:strip(function(pb)
|
pbullets:strip(function(pb)
|
||||||
if (pb:move()) return true
|
local disposition
|
||||||
|
repeat
|
||||||
|
disposition=pb:step()
|
||||||
for es in eship_collider:iterate_collisions(hurtbox(pb)) do
|
for es in eship_collider:iterate_collisions(hurtbox(pb)) do
|
||||||
if (es:hitbullet(pb)) eship_collider:yoink(es)
|
if (es:hitbullet(pb)) eship_collider:yoink(es)
|
||||||
if (pb:hitship(es)) return true
|
if (pb:hitship(es)) return true
|
||||||
end
|
end
|
||||||
|
until disposition
|
||||||
|
return disposition == "dead"
|
||||||
end)
|
end)
|
||||||
|
|
||||||
intangibles_fg:stripmove()
|
intangibles_fg:stripmove()
|
||||||
@ -692,9 +700,10 @@ end
|
|||||||
-- default: die, return true.
|
-- default: die, return true.
|
||||||
-- returns whether to delete
|
-- returns whether to delete
|
||||||
-- the bullet
|
-- the bullet
|
||||||
-- die -- on-removal event,
|
bullet_base = mknew{
|
||||||
-- default no-op
|
steps=1,
|
||||||
bullet_base = mknew{ }
|
current_step=0
|
||||||
|
}
|
||||||
|
|
||||||
gun_base = mknew{
|
gun_base = mknew{
|
||||||
shoot_ready = -32768,
|
shoot_ready = -32768,
|
||||||
@ -820,11 +829,13 @@ function bullet_base:hitship(_)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
function bullet_base:move()
|
function bullet_base:step()
|
||||||
|
self.current_step=(self.current_step+1)%self.steps
|
||||||
self.x += self.dx
|
self.x += self.dx
|
||||||
self.y += self.dy
|
self.y += self.dy
|
||||||
if (self.f) self.f -= 1
|
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
|
end
|
||||||
|
|
||||||
function bullet_base:draw()
|
function bullet_base:draw()
|
||||||
|
Reference in New Issue
Block a user