[WIP] Enviant als cacos a altra dimensió

[NEW] Tile per a warping
This commit is contained in:
2026-03-30 21:46:30 +02:00
parent 9e9a60b733
commit c9a4313e04
5 changed files with 229 additions and 33 deletions

View File

@@ -18,6 +18,11 @@ function caco.new(_hab,_x,_y,_flip)
frame=19,
wait=0,
step=0,
warping=false,
shrink=1,
d_shrink=0.1,
angle=0,
d_angle=5,
hit=caco.hit,
update=caco.update_normal,
draw=caco.draw,
@@ -30,9 +35,24 @@ function caco: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
local shrink_w = self.w*self.shrink
local shrink_h = self.h*self.shrink
local offset_x = (self.w-shrink_w)/2
local offset_y = (self.h-shrink_h)/2
local scr_x, scr_y = viewp:screen_coords( self.x+offset_x, self.y+offset_y )
draw.surfrot((self.frame&7)*cw, (self.frame>>cxr2)*ch,
cw, ch,
scr_x, scr_y,
self.angle,
shrink_w, shrink_h,
self.flip)
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
@@ -96,21 +116,44 @@ function caco:update_hit()
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=21
else
self.frame=-1
if self.warping then
if self.step<40 then
self.shrink=self.shrink-self.d_shrink
if self.shrink<0 then self.shrink=0 end
self.angle=self.angle+self.d_angle
if self.angle>=360 then
self.angle = 0
end
elseif self.step>=40 then
self.shrink=1
self.angle=0
self.frame=19
self.step=0
self.wait=0
self.warping = false
self.update=caco.update_normal
end
else
if self.step<40 then
if self.step%2==0 then
self.frame=21
else
self.frame=-1
end
elseif self.step>=40 then
self.frame=19
self.step=0
self.wait=0
self.update=caco.update_normal
end
elseif self.step>=40 then
self.frame=19
self.step=0
self.wait=0
self.update=caco.update_normal
end
end
end
function caco:hit()
self.update=caco.update_hit
self.warping=true
self.shrink=1
self.angle=0
end