warp={ max_warps=50, warp_list={}, update=update_all, } function warp.init() warp_sf=surf.new(32,32) surf.source(tiles) surf.target(warp_sf) local sprite_x = 11*16 local sprite_y = 15*16 draw.surfrot(sprite_x, sprite_y, 16, 16, 0, 0, 0) draw.surfrot(sprite_x, sprite_y, 16, 16, 15, 0, 90) draw.surfrot(sprite_x, sprite_y, 16, 16, 15, 15, 180) draw.surfrot(sprite_x, sprite_y, 16, 16, 0, 15, 270) end function warp.new(_actor) -- local world_x, world_y = coords.room_to_world(_hab,_x,_y) return {name="warp", hab=_hab, x=_actor.x, y=_actor.y, w=arcade_config.sprite_size.w, h=arcade_config.sprite_size.h, frame=0, wait=0, step=0, angle=0, d_angle=5, update=warp.update, draw=warp.draw, alive=true, actor=_actor} end function warp:draw() if not self.alive then return end local scr_x, scr_y = viewp:screen_coords( self.x, self.y ) local curr_sf=surf.source() surf.source(warp_sf) draw.surfrot(0,0,32,32,scr_x,scr_y,self.angle) surf.source(curr_sf) end function warp:update() if not self.actor.warping then self.alive=false end if not self.alive then return end self.wait=self.wait+1 self.angle=self.angle+self.d_angle if self.wait==10 then self.d_angle=self.d_angle+1 self.wait = 0 end if self.d_angle==20 then self.d_angle=5 self.alive = false end if self.angle>=360 then self.angle=self.angle % 360 end end function warp.open(actor) for _, w in ipairs(warp.warp_list) do if not w.alive then w.alive = true w.x = actor.x w.y = actor.y w.actor = actor return e; -- reutilitzar end end table.insert(warp.warp_list, warp.new(actor) ) end function warp.update_all() for _, w in ipairs(warp.warp_list) do if w.alive then w:update() end end end -- function warp:draw() -- if self.frame>0 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 warp: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)=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=warp.update_normal -- end -- end -- end -- -- function warp:hit() -- self.update=warp.update_hit -- end