[WIP] Treballant en el jefe. Super power done!
This commit is contained in:
@@ -6,11 +6,18 @@ fireball={
|
||||
wait=0,
|
||||
flip=false,
|
||||
step_length=3,
|
||||
bb={x=0,y=0,w=4,h=4}
|
||||
power=1,
|
||||
size=1,
|
||||
bb={x=0,y=0,w=4,h=4},
|
||||
x1=0,
|
||||
y1=0,
|
||||
step_length_x=1,
|
||||
step_length_y=1,
|
||||
}
|
||||
|
||||
function fireball.init(_hab,_x,_y,_flip, _off_x, _off_y)
|
||||
function fireball.init(_hab,_x,_y,_flip, _off_x, _off_y, _power)
|
||||
local world_x, world_y = coords.room_to_world(_hab,_x,_y)
|
||||
_power = _power or 1
|
||||
if fireball.hab ~= -1 then return end
|
||||
_off_x = _off_x or 0
|
||||
_off_y = _off_y or 0
|
||||
@@ -18,19 +25,63 @@ function fireball.init(_hab,_x,_y,_flip, _off_x, _off_y)
|
||||
fireball.x= world_x+_off_x
|
||||
fireball.y= world_y+_off_y
|
||||
fireball.flip=_flip
|
||||
fireball.power=_power
|
||||
fireball.size=1
|
||||
fireball.w = 6
|
||||
fireball.h = 6
|
||||
fireball.bb = {x=0,y=0,w=4,h=4}
|
||||
end
|
||||
|
||||
function fireball.draw()
|
||||
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)
|
||||
draw.circf(scr_x,scr_y,8*fireball.size,16)
|
||||
draw.circf(scr_x,scr_y,6*fireball.size,3)
|
||||
draw.circf(scr_x,scr_y,2*fireball.size,8)
|
||||
end
|
||||
|
||||
function fireball.update()
|
||||
if fireball.power==2 and fireball.power>fireball.size then
|
||||
fireball.wait = fireball.wait + 1
|
||||
fireball.x1=abad.x+abad.bb.x+(abad.bb.w//2)
|
||||
fireball.y1=abad.y
|
||||
if abad.x<fireball.x then
|
||||
fireball.step_length_x = -1
|
||||
else
|
||||
fireball.step_length_x = 1
|
||||
end
|
||||
if abad.y<fireball.y then
|
||||
fireball.step_length_y = -1
|
||||
else
|
||||
fireball.step_length_y = 1
|
||||
end
|
||||
if fireball.wait==6 then
|
||||
fireball.size = fireball.size+0.1
|
||||
fireball.wait = 0
|
||||
end
|
||||
|
||||
local dx = math.abs(fireball.x-fireball.x1)
|
||||
local dy = math.abs(fireball.y-fireball.y1)
|
||||
if dx<dy then
|
||||
if dy~=0 then
|
||||
fireball.step_length_x = fireball.step_length_x*(dx/dy)*2
|
||||
fireball.step_length_y = fireball.step_length_y*2
|
||||
end
|
||||
else
|
||||
if dx~=0 then
|
||||
fireball.step_length_x = fireball.step_length_x*2
|
||||
fireball.step_length_y = fireball.step_length_y*(dy/dx)*2
|
||||
end
|
||||
end
|
||||
fireball.w=6*fireball.size
|
||||
fireball.h=fireball.w
|
||||
fireball.bb = {x=0,y=0,w=4*fireball.size,h=4*fireball.size}
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
if fireball.hab == -1 then return end
|
||||
fireball.wait=fireball.wait+1
|
||||
-- fireball.wait=fireball.wait+1
|
||||
|
||||
--if fireball.wait==3 then
|
||||
fireball.wait=0
|
||||
@@ -39,23 +90,33 @@ function fireball.update()
|
||||
-- fireball.hab=-1
|
||||
-- return
|
||||
--end
|
||||
|
||||
if arc_check_tile(fireball.x,fireball.y)<tiletype.block then
|
||||
if fireball.flip then
|
||||
fireball.x=fireball.x-fireball.step_length
|
||||
if fireball.power==1 then
|
||||
if arc_check_tile(fireball.x,fireball.y)<tiletype.block then
|
||||
if fireball.flip then
|
||||
fireball.x=fireball.x-fireball.step_length
|
||||
else
|
||||
fireball.x=fireball.x+fireball.step_length
|
||||
end
|
||||
else
|
||||
fireball.x=fireball.x+fireball.step_length
|
||||
fireball.hab=-1
|
||||
return
|
||||
end
|
||||
else
|
||||
fireball.hab=-1
|
||||
return
|
||||
elseif fireball.power==2 then
|
||||
fireball.x = fireball.x+fireball.step_length_x
|
||||
fireball.y = fireball.y+fireball.step_length_y
|
||||
end
|
||||
|
||||
if viewp:inside(fireball.x, fireball.y, fireball.w, fireball.h) then
|
||||
if collision(fireball,abad) and abad.update~=abad_state_crouch then
|
||||
if collision(fireball,abad) then
|
||||
if fireball.power==1 and abad.update~=abad_state_crouch then
|
||||
abad_hurt(1)
|
||||
elseif fireball.power==2 then
|
||||
abad_hurt(2)
|
||||
end
|
||||
fireball.hab=-1
|
||||
abad_hurt(1)
|
||||
end
|
||||
else
|
||||
fireball.hab=-1
|
||||
end
|
||||
--end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user