Zombies arounding i caco upgradat
This commit is contained in:
@@ -22,7 +22,7 @@ function caco.new(_hab,_x,_y,_flip)
|
|||||||
draw=caco.draw,
|
draw=caco.draw,
|
||||||
jumpfwd=false,
|
jumpfwd=false,
|
||||||
anim={19,19,20,21},
|
anim={19,19,20,21},
|
||||||
bb={x=2,y=4,w=12,h=8} }
|
bb={x=4,y=4,w=24,h=16} }
|
||||||
end
|
end
|
||||||
|
|
||||||
function caco:draw()
|
function caco:draw()
|
||||||
@@ -36,25 +36,43 @@ function caco:draw()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function caco:update_normal()
|
function caco:update_normal()
|
||||||
self.wait=0
|
self.wait=self.wait+1
|
||||||
self.step=self.step+1
|
|
||||||
if self.step<50 then
|
if self.wait==6 then
|
||||||
self.frame=19
|
self.wait=0
|
||||||
elseif self.step==70 then
|
self.step=self.step+1
|
||||||
self.frame=20
|
if self.step<8 then
|
||||||
elseif self.step==80 then
|
self.frame=19
|
||||||
self.frame=21
|
elseif self.step==12 then
|
||||||
elseif self.step==90 then
|
self.frame=20
|
||||||
self.step=0
|
elseif self.step==13 then
|
||||||
|
self.frame=21
|
||||||
|
elseif self.step==15 then
|
||||||
|
self.step=0
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local step = 1
|
local step = 1
|
||||||
if self.flip then step = -step end
|
if self.flip then step = -step end
|
||||||
if arc_check_tile(self.x+step,self.y+self.h)<tiletype.block then
|
local inc = 0
|
||||||
|
if self.flip then inc = self.bb.w end
|
||||||
|
|
||||||
|
local check_x = self.x+self.bb.x+step
|
||||||
|
local check_ywall1 = self.y+self.bb.y
|
||||||
|
local check_ywall2 = self.y+self.h-2
|
||||||
|
if not self.flip then
|
||||||
|
check_x = self.x+self.bb.w+self.bb.x+step
|
||||||
|
end
|
||||||
|
|
||||||
|
local check_no_wall1= arc_check_tile(check_x,check_ywall1)<tiletype.block
|
||||||
|
local check_no_wall2= arc_check_tile(check_x,check_ywall2)<tiletype.block
|
||||||
|
if check_no_wall1 and check_no_wall2 then
|
||||||
self.x=self.x+step
|
self.x=self.x+step
|
||||||
else
|
else
|
||||||
self.flip=not self.flip
|
self.flip=not self.flip
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- if self.hab==abad.hab then
|
-- if self.hab==abad.hab then
|
||||||
-- if aabb(abad,self) then
|
-- if aabb(abad,self) then
|
||||||
-- abad_hurt(1)
|
-- abad_hurt(1)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ require "mapa"
|
|||||||
require "abad"
|
require "abad"
|
||||||
require "cacau"
|
require "cacau"
|
||||||
require "caco"
|
require "caco"
|
||||||
|
require "zombie"
|
||||||
|
|
||||||
local tile_w = arcade_config.tiles_width
|
local tile_w = arcade_config.tiles_width
|
||||||
local tile_h = arcade_config.tiles_height
|
local tile_h = arcade_config.tiles_height
|
||||||
@@ -34,6 +35,16 @@ function game_init(menu)
|
|||||||
table.insert( actors, caco.new(57,3,2,false) )
|
table.insert( actors, caco.new(57,3,2,false) )
|
||||||
table.insert( actors, caco.new(61,3,2,false) )
|
table.insert( actors, caco.new(61,3,2,false) )
|
||||||
|
|
||||||
|
table.insert( actors, zombie.new(11, 3, 3,true) )
|
||||||
|
-- table.insert( actors, zombie.new(2, 3, 3,false) )
|
||||||
|
-- table.insert( actors, zombie.new(28, 3, 3,false) )
|
||||||
|
-- table.insert( actors, zombie.new(32, 3, 3,false) )
|
||||||
|
-- table.insert( actors, zombie.new(44, 3, 3,false) )
|
||||||
|
-- table.insert( actors, zombie.new(46, 3, 3,false) )
|
||||||
|
-- table.insert( actors, zombie.new(54, 3, 3,false) )
|
||||||
|
-- table.insert( actors, zombie.new(68, 3, 3,false) )
|
||||||
|
-- table.insert( actors, zombie.new(73, 3, 3,false) )
|
||||||
|
|
||||||
local abad_x, abad_y = arc_mapa_get_coords ( 10, 4, 3 )
|
local abad_x, abad_y = arc_mapa_get_coords ( 10, 4, 3 )
|
||||||
abad:move(abad_x, abad_y)
|
abad:move(abad_x, abad_y)
|
||||||
|
|
||||||
|
|||||||
100
data/zombie.lua
Normal file
100
data/zombie.lua
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
local arcade_config = require("arcade_config")
|
||||||
|
o2aX = arcade_config.org2arc_escala
|
||||||
|
cxr = arcade_config.character_per_row-1
|
||||||
|
cxr2 = arcade_config.character_per_row_base2
|
||||||
|
cw = arcade_config.character_width
|
||||||
|
ch = arcade_config.character_height
|
||||||
|
|
||||||
|
zombie={}
|
||||||
|
|
||||||
|
function zombie.new(_hab,_x,_y,_flip)
|
||||||
|
local world_x, world_y = arc_mapa_get_coords(_hab,_x,_y)
|
||||||
|
return {hab=_hab,
|
||||||
|
x=world_x,
|
||||||
|
y=world_y,
|
||||||
|
w=arcade_config.sprite_size.w,
|
||||||
|
h=arcade_config.sprite_size.h,
|
||||||
|
flip=_flip,
|
||||||
|
frame=0,
|
||||||
|
wait=0,
|
||||||
|
step=0,
|
||||||
|
hit=zombie.hit,
|
||||||
|
update=zombie.update_normal,
|
||||||
|
draw=zombie.draw,
|
||||||
|
jumpfwd=false,
|
||||||
|
anim={16,17,16,18},
|
||||||
|
bb={x=4,y=0,w=26,h=32}}
|
||||||
|
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 and viewp:inside(self.x, self.y, self.w, self.h) 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
|
||||||
|
|
||||||
|
function zombie:update_normal()
|
||||||
|
self.wait=self.wait+1
|
||||||
|
|
||||||
|
if self.wait==18 then
|
||||||
|
self.wait=0
|
||||||
|
self.step=(self.step+1)%4
|
||||||
|
self.frame=self.anim[self.step+1]
|
||||||
|
end
|
||||||
|
|
||||||
|
local step = 1
|
||||||
|
if self.flip then step = -step end
|
||||||
|
local inc = 0
|
||||||
|
if self.flip then inc = self.bb.w end
|
||||||
|
|
||||||
|
local check_x = self.x+self.bb.x+step
|
||||||
|
local check_ywall = self.y+self.h-2
|
||||||
|
local check_yhole = self.y+self.h+1
|
||||||
|
if not self.flip then
|
||||||
|
check_x = self.x+self.bb.w+self.bb.x+step
|
||||||
|
end
|
||||||
|
|
||||||
|
local check_no_wall= arc_check_tile(check_x,check_ywall)<tiletype.block
|
||||||
|
local check_no_hole= arc_check_tile(check_x,check_yhole)~=tiletype.void
|
||||||
|
if check_no_wall and check_no_hole then
|
||||||
|
self.x=self.x+step
|
||||||
|
else
|
||||||
|
self.flip=not self.flip
|
||||||
|
end
|
||||||
|
|
||||||
|
-- if self.hab==abad.hab then
|
||||||
|
-- if aabb(abad,self) then
|
||||||
|
-- abad_hurt(1)
|
||||||
|
-- end
|
||||||
|
-- end
|
||||||
|
|
||||||
|
--if check_tile(self.hab,self.x+4,self.y+16)==tiletype.void and ((self.x+4)&7==0 or check_tile(self.hab,self.x+12,self.y+16)==tiletype.void) then
|
||||||
|
-- self.flip=not self.flip
|
||||||
|
--end
|
||||||
|
end
|
||||||
|
|
||||||
|
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
|
||||||
|
end
|
||||||
|
elseif self.step>=40 then
|
||||||
|
self.step=0
|
||||||
|
self.wait=0
|
||||||
|
self.update=zombie.update_normal
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function zombie:hit()
|
||||||
|
self.update=zombie.update_hit
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user