Zombies interdimensionals done!
This commit is contained in:
110
data/caco.lua
110
data/caco.lua
@@ -36,22 +36,23 @@ 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)*16,(self.frame>>3)*16,16,16,self.x,self.y,16,16,self.flip) end
|
||||||
|
|
||||||
if self.warping then
|
if self.warping then
|
||||||
local shrink_w = self.w*self.shrink
|
-- local shrink_w = self.w*self.shrink
|
||||||
local shrink_h = self.h*self.shrink
|
-- local shrink_h = self.h*self.shrink
|
||||||
local offset_x = math.floor((self.w-shrink_w)/2)
|
-- local offset_x = math.floor((self.w-shrink_w)/2)
|
||||||
local offset_y = math.floor((self.h-shrink_h)/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 )
|
-- local scr_x, scr_y = viewp:screen_coords( self.x+offset_x, self.y+offset_y )
|
||||||
shrink_w = math.floor(shrink_w)
|
-- shrink_w = math.floor(shrink_w)
|
||||||
shrink_h = math.floor(shrink_h)
|
-- 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
|
-- if shrink_w>0 and shrink_h>0 then
|
||||||
draw.surfrot((self.frame&7)*cw, (self.frame>>cxr2)*ch,
|
-- draw.surfrot((self.frame&7)*cw, (self.frame>>cxr2)*ch,
|
||||||
cw, ch,
|
-- cw, ch,
|
||||||
scr_x, scr_y,
|
-- scr_x, scr_y,
|
||||||
self.angle,
|
-- self.angle,
|
||||||
shrink_w, shrink_h,
|
-- shrink_w, shrink_h,
|
||||||
self.flip)
|
-- self.flip)
|
||||||
end
|
-- end
|
||||||
|
actor_warp_draw(self)
|
||||||
else
|
else
|
||||||
if self.frame>0 then
|
if self.frame>0 then
|
||||||
local scr_x, scr_y = viewp:screen_coords( self.x, self.y )
|
local scr_x, scr_y = viewp:screen_coords( self.x, self.y )
|
||||||
@@ -127,46 +128,49 @@ function caco:update_hit()
|
|||||||
self.step=self.step+1
|
self.step=self.step+1
|
||||||
|
|
||||||
if self.can_warp then
|
if self.can_warp then
|
||||||
-- warp, wait, respawn
|
-- -- warp, wait, respawn
|
||||||
if self.warping then
|
-- 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<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>=self.death_time then
|
||||||
|
-- self.frame=19
|
||||||
|
-- self.step=0
|
||||||
|
-- self.wait=0
|
||||||
|
-- self.update=caco.update_normal
|
||||||
|
-- self.dying = false
|
||||||
|
-- end
|
||||||
|
actor_warp_update(self)
|
||||||
|
else
|
||||||
if self.step<self.death_time 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<self.death_time/2 then
|
|
||||||
self.frame = -1
|
|
||||||
elseif self.step<self.death_time then
|
|
||||||
if self.step%2==0 then
|
if self.step%2==0 then
|
||||||
self.frame=21
|
-- self.frame=21
|
||||||
|
self.frame=self.anim[4]
|
||||||
else
|
else
|
||||||
self.frame=-1
|
self.frame=-1
|
||||||
end
|
end
|
||||||
elseif self.step>=self.death_time then
|
elseif self.step>=self.death_time then
|
||||||
self.frame=19
|
-- self.frame=19
|
||||||
self.step=0
|
self.frame=self.anim[1]
|
||||||
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.step=0
|
||||||
self.wait=0
|
self.wait=0
|
||||||
self.update=caco.update_normal
|
self.update=caco.update_normal
|
||||||
@@ -178,15 +182,13 @@ end
|
|||||||
|
|
||||||
function caco:hit()
|
function caco:hit()
|
||||||
self.update=caco.update_hit
|
self.update=caco.update_hit
|
||||||
self.warping=true
|
|
||||||
|
if self.can_warp then self.warping=true end
|
||||||
self.shrink=1
|
self.shrink=1
|
||||||
self.angle=0
|
self.angle=0
|
||||||
self.dying=true
|
self.dying=true
|
||||||
-- calcular velocitat per al warp
|
-- calcular velocitat per al warp
|
||||||
local warp_time = self.death_time/3
|
local warp_time = self.death_time/3
|
||||||
-- print(warp_time); -- 13.33
|
|
||||||
self.d_angle = 720 / warp_time; -- 720 = 2 voltes
|
self.d_angle = 720 / warp_time; -- 720 = 2 voltes
|
||||||
-- print(self.d_angle); -- 54
|
|
||||||
self.d_shrink = self.shrink / warp_time
|
self.d_shrink = self.shrink / warp_time
|
||||||
-- print(self.d_shrink); -- 2.4
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -23,6 +23,63 @@ local view_checking_tile = false
|
|||||||
viewp = viewport.new(arcade_config.resolucion.width, arcade_config.resolucion.height)
|
viewp = viewport.new(arcade_config.resolucion.width, arcade_config.resolucion.height)
|
||||||
viewp:position(0,0)
|
viewp:position(0,0)
|
||||||
|
|
||||||
|
function actor_warp_draw(actor)
|
||||||
|
local shrink_w = actor.w*actor.shrink
|
||||||
|
local shrink_h = actor.h*actor.shrink
|
||||||
|
local offset_x = math.floor((actor.w-shrink_w)/2)
|
||||||
|
local offset_y = math.floor((actor.h-shrink_h)/2)
|
||||||
|
local scr_x, scr_y = viewp:screen_coords( actor.x+offset_x, actor.y+offset_y )
|
||||||
|
shrink_w = math.floor(shrink_w)
|
||||||
|
shrink_h = math.floor(shrink_h)
|
||||||
|
|
||||||
|
if shrink_w>0 and shrink_h>0 then
|
||||||
|
draw.surfrot((actor.frame&7)*cw, (actor.frame>>cxr2)*ch,
|
||||||
|
cw, ch,
|
||||||
|
scr_x, scr_y,
|
||||||
|
actor.angle,
|
||||||
|
shrink_w, shrink_h,
|
||||||
|
actor.flip)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function actor_warp_update(actor)
|
||||||
|
-- warp, wait, respawn
|
||||||
|
if actor.warping then
|
||||||
|
if actor.step<actor.death_time then
|
||||||
|
actor.shrink=actor.shrink-actor.d_shrink
|
||||||
|
actor.angle=actor.angle+actor.d_angle
|
||||||
|
if actor.angle>=360 then actor.angle = actor.angle % 360 end
|
||||||
|
if actor.shrink<=0 then
|
||||||
|
actor.shrink=1
|
||||||
|
actor.d_shrink=1
|
||||||
|
actor.angle=0
|
||||||
|
actor.d_angle=1
|
||||||
|
actor.warping = false
|
||||||
|
actor.frame = -1
|
||||||
|
actor.step = 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elseif actor.step<actor.death_time/2 then
|
||||||
|
actor.frame = -1
|
||||||
|
elseif actor.step<actor.death_time then
|
||||||
|
if actor.step%2==0 then
|
||||||
|
actor.frame=actor.anim[4]
|
||||||
|
else
|
||||||
|
actor.frame=-1
|
||||||
|
end
|
||||||
|
elseif actor.step>=actor.death_time then
|
||||||
|
actor.frame=actor.anim[1]
|
||||||
|
actor.step=0
|
||||||
|
actor.wait=0
|
||||||
|
if actor.name=="caco" then
|
||||||
|
actor.update=caco.update_normal
|
||||||
|
elseif actor.name=="zombie" then
|
||||||
|
actor.update=zombie.update_normal
|
||||||
|
end
|
||||||
|
actor.dying = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
actors={}
|
actors={}
|
||||||
|
|
||||||
function game_init(menu)
|
function game_init(menu)
|
||||||
|
|||||||
@@ -21,17 +21,29 @@ function zombie.new(_hab,_x,_y,_flip)
|
|||||||
draw=zombie.draw,
|
draw=zombie.draw,
|
||||||
jumpfwd=false,
|
jumpfwd=false,
|
||||||
anim={16,17,16,18},
|
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
|
end
|
||||||
|
|
||||||
function zombie:draw()
|
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)*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 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
|
||||||
|
actor_warp_draw(self)
|
||||||
|
else
|
||||||
if self.frame>0 then
|
if self.frame>0 then
|
||||||
local scr_x, scr_y = viewp:screen_coords( self.x, self.y )
|
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)
|
draw.surf((self.frame&7)*cw, (self.frame>>cxr2)*ch, cw, ch, scr_x, scr_y, cw, ch, self.flip)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function zombie:update_normal()
|
function zombie:update_normal()
|
||||||
self.wait=self.wait+1
|
self.wait=self.wait+1
|
||||||
@@ -85,20 +97,38 @@ function zombie:update_hit()
|
|||||||
if self.wait>=6 then
|
if self.wait>=6 then
|
||||||
self.wait=0
|
self.wait=0
|
||||||
self.step=self.step+1
|
self.step=self.step+1
|
||||||
if self.step<40 then
|
|
||||||
|
if self.can_warp then
|
||||||
|
actor_warp_update(self)
|
||||||
|
else
|
||||||
|
if self.step<self.death_time then
|
||||||
if self.step%2==0 then
|
if self.step%2==0 then
|
||||||
self.frame=16
|
self.frame=self.anim[4]
|
||||||
else
|
else
|
||||||
self.frame=-1
|
self.frame=-1
|
||||||
end
|
end
|
||||||
elseif self.step>=40 then
|
elseif self.step>=self.death_time then
|
||||||
|
self.frame=self.anim[0]
|
||||||
self.step=0
|
self.step=0
|
||||||
self.wait=0
|
self.wait=0
|
||||||
self.update=zombie.update_normal
|
self.update=caco.update_normal
|
||||||
|
self.dying = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
function zombie:hit()
|
function zombie:hit()
|
||||||
self.update=zombie.update_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
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user