diff --git a/data/fireball.lua b/data/fireball.lua index 7500a63..45b9370 100644 --- a/data/fireball.lua +++ b/data/fireball.lua @@ -1,52 +1,61 @@ -local arcade_config = require("arcade_config") -o2aX = arcade_config.org2arc_escala -fireball={hab=-1,x=0,y=0,wait=0,flip=false,bb={x=0,y=0,w=4,h=4}} +fireball={ + hab=-1, + x=0, y=0, + w=6, h=6, + wait=0, + flip=false, + step_length=3, + bb={x=0,y=0,w=4,h=4} +} -function fireball.init(_hab,_x,_y,_flip) +function fireball.init(_hab,_x,_y,_flip, _off_x, _off_y) + local world_x, world_y = coords.room_to_world(_hab,_x,_y) if fireball.hab ~= -1 then return end + _off_x = _off_x or 0 + _off_y = _off_y or 0 fireball.hab=_hab - fireball.x=_x - fireball.y=_y + fireball.x= world_x+_off_x + fireball.y= world_y+_off_y fireball.flip=_flip end function fireball.draw() - draw.circf(fireball.x*o2aX,fireball.y*o2aX,3*o2aX,16) - draw.circf(fireball.x*o2aX,fireball.y*o2aX,2*o2aX,3) - draw.circf(fireball.x*o2aX,fireball.y*o2aX,1*o2aX,8) + if fireball.hab == -1 then return end + local scr_x, scr_y = viewp:screen_coords( fireball.x, fireball.y ) + draw.circf(scr_x,scr_y,8,16) + draw.circf(scr_x,scr_y,6,3) + draw.circf(scr_x,scr_y,2,8) end function fireball.update() if fireball.hab == -1 then return end fireball.wait=fireball.wait+1 - if fireball.wait==3 then + --if fireball.wait==3 then fireball.wait=0 - if fireball.x>96 then - fireball.hab=-1 - return - elseif check_tile(fireball.hab,fireball.x,fireball.y)abad.x then + flip=true + x_ini = self.x-4 + end + local hab, tx, ty, off_x, off_y = coords.world_to_tile(x_ini,self.y+(self.h/2)) + fireball.init(hab, tx, ty, flip, off_x, off_y) + sound.play(audio_hit) + self.shot_cooldown = 500 end @@ -1029,26 +1040,5 @@ if DEBUG_FN_NAME then print("move "..self.fight_mode) end -- -- imp.step=(imp.step+1)%4 -- imp.frame=imp.anim[imp.step+1] - -- - -- if imp.flip then - -- imp.x=imp.x-2 - -- if imp.x==78 then - -- fireball.init(imp.hab,imp.x+8,imp.y+4,imp.flip) - -- sound.play(audio_hit) - -- imp.flip=not imp.flip - -- elseif imp.x==-12 then - -- imp.reset() - -- end - -- else - -- imp.x=imp.x+2 - -- if imp.x==4 then - -- fireball.init(imp.hab,imp.x+8,imp.y+4,imp.flip) - -- sound.play(audio_hit) - -- imp.flip=not imp.flip - -- elseif imp.x==92 then - -- imp.reset() - -- end - -- end - -- --end end