first commit
This commit is contained in:
80
caco.lua
Normal file
80
caco.lua
Normal file
@@ -0,0 +1,80 @@
|
||||
caco={}
|
||||
|
||||
function caco.new(_hab,_x,_y)
|
||||
return {hab=_hab,x=_x,y=_y,flip=false,frame=0,wait=0,step=0,hit=caco.hit,update=caco.update_normal,draw=caco.draw,jumpfwd=false,anim={19,19,20,21},bb={x=2,y=0,w=12,h=16}}
|
||||
end
|
||||
|
||||
function caco:draw()
|
||||
sspr((self.frame&7)*16,(self.frame>>3)*16,16,16,self.x,self.y,16,16,self.flip)
|
||||
end
|
||||
|
||||
function caco:update_normal()
|
||||
self.wait=self.wait+1
|
||||
|
||||
if self.wait==6 then
|
||||
self.wait=0
|
||||
self.step=self.step+1
|
||||
if self.step<12 then
|
||||
self.frame=19
|
||||
elseif self.step==12 then
|
||||
self.frame=20
|
||||
elseif self.step==13 then
|
||||
self.frame=21
|
||||
self.step=0
|
||||
end
|
||||
|
||||
local inc=14 if self.flip then inc=0 end
|
||||
if not self.flip and self.x==84 then
|
||||
self.hab=self.hab+1
|
||||
self.x=-4
|
||||
elseif check_tile(self.hab,self.x+inc,self.y+14)<tiletype.block then
|
||||
if self.flip then
|
||||
self.x=self.x-2
|
||||
else
|
||||
self.x=self.x+2
|
||||
end
|
||||
if self.x<-4 then
|
||||
self.hab=self.hab-1
|
||||
self.x=84
|
||||
end
|
||||
else
|
||||
self.flip=not self.flip
|
||||
end
|
||||
|
||||
if self.hab==abad.hab then
|
||||
if aabb(abad,self) then
|
||||
if abad.energia>0 then abad.energia=abad.energia-1 end
|
||||
cls(3)
|
||||
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
|
||||
end
|
||||
|
||||
function caco: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=21
|
||||
else
|
||||
self.frame=7
|
||||
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
|
||||
end
|
||||
Reference in New Issue
Block a user