Zombies interdimensionals done!

This commit is contained in:
2026-03-31 21:31:16 +02:00
parent 1708be71a8
commit 205a98bf17
3 changed files with 157 additions and 68 deletions

View File

@@ -21,15 +21,27 @@ function zombie.new(_hab,_x,_y,_flip)
draw=zombie.draw,
jumpfwd=false,
anim={16,17,16,18},
bb={x=4,y=0,w=26,h=32}}
bb={x=4,y=0,w=26,h=32},
can_warp=true,
warping=false,
shrink=1,
d_shrink=1,
angle=0,
d_angle=15,
dying=false,
death_time=40}
end
function zombie:draw()
-- if self.frame>0 then draw.surf((self.frame&7)*16,(self.frame>>3)*16,16,16,self.x,self.y,16,16,self.flip) end
-- if self.frame>0 then draw.surf((self.frame&7)*cw,(self.frame>>cxr2)*ch,cw,ch,self.x*o2aX,self.y*o2aX,cw,ch,self.flip) end
if self.frame>0 then
local scr_x, scr_y = viewp:screen_coords( self.x, self.y )
draw.surf((self.frame&7)*cw, (self.frame>>cxr2)*ch, cw, ch, scr_x, scr_y, cw, ch, self.flip)
if self.warping then
actor_warp_draw(self)
else
if self.frame>0 then
local scr_x, scr_y = viewp:screen_coords( self.x, self.y )
draw.surf((self.frame&7)*cw, (self.frame>>cxr2)*ch, cw, ch, scr_x, scr_y, cw, ch, self.flip)
end
end
end
@@ -79,26 +91,44 @@ function zombie:update_normal()
--end
end
function zombie:update_hit()
function zombie:update_hit()
self.wait=self.wait+1
if self.wait>=6 then
self.wait=0
self.step=self.step+1
if self.step<40 then
if self.step%2==0 then
self.frame=16
else
self.frame=-1
if self.can_warp then
actor_warp_update(self)
else
if self.step<self.death_time then
if self.step%2==0 then
self.frame=self.anim[4]
else
self.frame=-1
end
elseif self.step>=self.death_time then
self.frame=self.anim[0]
self.step=0
self.wait=0
self.update=caco.update_normal
self.dying = false
end
elseif self.step>=40 then
self.step=0
self.wait=0
self.update=zombie.update_normal
end
end
end
end
function zombie:hit()
self.update=zombie.update_hit
if self.can_warp then self.warping=true end
self.shrink=1
self.angle=0
self.dying=true
-- calcular velocitat per al warp
local warp_time = self.death_time/3
self.d_angle = 720 / warp_time; -- 720 = 2 voltes
self.d_shrink = self.shrink / warp_time
end