Cacos interdimensionals done!
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
local arcade_config = require("arcade_config")
|
||||
o2aX = arcade_config.org2arc_escala
|
||||
cxr2 = arcade_config.character_per_row_base2
|
||||
cw = arcade_config.character_width
|
||||
ch = arcade_config.character_height
|
||||
@@ -18,15 +16,18 @@ function caco.new(_hab,_x,_y,_flip)
|
||||
frame=19,
|
||||
wait=0,
|
||||
step=0,
|
||||
can_warp=true,
|
||||
warping=false,
|
||||
shrink=1,
|
||||
d_shrink=0.1,
|
||||
d_shrink=1,
|
||||
angle=0,
|
||||
d_angle=5,
|
||||
d_angle=15,
|
||||
hit=caco.hit,
|
||||
update=caco.update_normal,
|
||||
draw=caco.draw,
|
||||
jumpfwd=false,
|
||||
dying=false,
|
||||
death_time=40,
|
||||
anim={19,19,20,21},
|
||||
bb={x=4,y=4,w=24,h=16} }
|
||||
end
|
||||
@@ -34,20 +35,23 @@ end
|
||||
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.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 offset_x = math.floor((self.w-shrink_w)/2)
|
||||
local offset_y = math.floor((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)
|
||||
shrink_w = math.floor(shrink_w)
|
||||
shrink_h = math.floor(shrink_h)
|
||||
-- print(shrink_w..", "..shrink_h..", "..offset_x..", "..offset_y..", "..scr_x..", "..scr_y)
|
||||
if shrink_w>0 and shrink_h>0 then
|
||||
draw.surfrot((self.frame&7)*cw, (self.frame>>cxr2)*ch,
|
||||
cw, ch,
|
||||
scr_x, scr_y,
|
||||
self.angle,
|
||||
shrink_w, shrink_h,
|
||||
self.flip)
|
||||
end
|
||||
else
|
||||
if self.frame>0 then
|
||||
local scr_x, scr_y = viewp:screen_coords( self.x, self.y )
|
||||
@@ -111,41 +115,62 @@ function caco:update_normal()
|
||||
end
|
||||
|
||||
function caco:update_hit()
|
||||
local step_time = self.death_time
|
||||
if self.can_warp then
|
||||
step_time = self.death_time/3; -- warp, wait, appear
|
||||
end
|
||||
|
||||
self.wait=self.wait+1
|
||||
|
||||
if self.wait>=6 then
|
||||
self.wait=0
|
||||
self.step=self.step+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
|
||||
if self.can_warp then
|
||||
-- warp, wait, respawn
|
||||
if self.warping then
|
||||
if self.step<self.death_time then
|
||||
self.shrink=self.shrink-self.d_shrink
|
||||
self.angle=self.angle+self.d_angle
|
||||
if self.angle>=360 then self.angle = self.angle % 360 end
|
||||
if self.shrink<=0 then
|
||||
self.shrink=1
|
||||
self.d_shrink=1
|
||||
self.angle=0
|
||||
self.d_angle=1
|
||||
self.warping = false
|
||||
self.frame = -1
|
||||
self.step = 0
|
||||
end
|
||||
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
|
||||
elseif self.step<self.death_time/2 then
|
||||
self.frame = -1
|
||||
elseif self.step<self.death_time then
|
||||
if self.step%2==0 then
|
||||
self.frame=21
|
||||
else
|
||||
self.frame=-1
|
||||
end
|
||||
elseif self.step>=40 then
|
||||
elseif self.step>=self.death_time then
|
||||
self.frame=19
|
||||
self.step=0
|
||||
self.wait=0
|
||||
self.update=caco.update_normal
|
||||
self.dying = false
|
||||
end
|
||||
else
|
||||
if self.step<self.death_time then
|
||||
if self.step%2==0 then
|
||||
self.frame=21
|
||||
else
|
||||
self.frame=-1
|
||||
end
|
||||
elseif self.step>=self.death_time then
|
||||
self.frame=19
|
||||
self.step=0
|
||||
self.wait=0
|
||||
self.update=caco.update_normal
|
||||
self.dying = false
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -156,4 +181,12 @@ function caco:hit()
|
||||
self.warping=true
|
||||
self.shrink=1
|
||||
self.angle=0
|
||||
self.dying=true
|
||||
-- calcular velocitat per al warp
|
||||
local warp_time = self.death_time/3
|
||||
-- print(warp_time); -- 13.33
|
||||
self.d_angle = 720 / warp_time; -- 720 = 2 voltes
|
||||
-- print(self.d_angle); -- 54
|
||||
self.d_shrink = self.shrink / warp_time
|
||||
-- print(self.d_shrink); -- 2.4
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user