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 caco={} function caco.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=19, wait=0, step=0, hit=caco.hit, update=caco.update_normal, draw=caco.draw, jumpfwd=false, anim={19,19,20,21}, bb={x=4,y=4,w=24,h=16} } 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.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 caco:update_normal() self.wait=self.wait+1 if self.wait==6 then self.wait=0 self.step=self.step+1 if self.step<8 then self.frame=19 elseif self.step==12 then self.frame=20 elseif self.step==13 then self.frame=21 elseif self.step==15 then self.step=0 end 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_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)=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