[WIP] Treballant en el jefe. Dispar complet
This commit is contained in:
@@ -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)<tiletype.block then
|
||||
--if viewp:inside(fireball.x, fireball.y, fireball.w, fireball.h)==false then
|
||||
-- fireball.hab=-1
|
||||
-- return
|
||||
--end
|
||||
|
||||
if arc_check_tile(fireball.x,fireball.y)<tiletype.block then
|
||||
if fireball.flip then
|
||||
fireball.x=fireball.x-4
|
||||
fireball.x=fireball.x-fireball.step_length
|
||||
else
|
||||
fireball.x=fireball.x+4
|
||||
end
|
||||
if fireball.x<-4 then
|
||||
fireball.hab=-1
|
||||
return
|
||||
fireball.x=fireball.x+fireball.step_length
|
||||
end
|
||||
else
|
||||
fireball.hab=-1
|
||||
return
|
||||
end
|
||||
|
||||
if fireball.hab==abad.hab then
|
||||
if aabb(fireball,abad) and abad.update~=abad_state_crouch then
|
||||
if viewp:inside(fireball.x, fireball.y, fireball.w, fireball.h) then
|
||||
if collision(fireball,abad) and abad.update~=abad_state_crouch then
|
||||
fireball.hab=-1
|
||||
abad_hurt(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
--end
|
||||
end
|
||||
|
||||
@@ -15,6 +15,7 @@ require "score"
|
||||
-- require "switches"
|
||||
require "trigger"
|
||||
require "imp"
|
||||
require "fireball"
|
||||
|
||||
require "stage1"
|
||||
require "remote_view"
|
||||
@@ -191,6 +192,7 @@ function world_update()
|
||||
|
||||
-- Actualizar el que queda
|
||||
cacau.update()
|
||||
fireball.update()
|
||||
-- switches.update()
|
||||
warp.update_all()
|
||||
end
|
||||
@@ -214,6 +216,7 @@ function world_draw()
|
||||
end
|
||||
|
||||
cacau:draw()
|
||||
fireball.draw()
|
||||
|
||||
remote_view_draw()
|
||||
end
|
||||
|
||||
32
data/imp.lua
32
data/imp.lua
@@ -500,6 +500,17 @@ if DEBUG_FN_NAME then print("shot") end
|
||||
self:do_flip(abad)
|
||||
self.flip_wait=100
|
||||
print("FIREBALL!!")
|
||||
|
||||
local flip = false
|
||||
local x_ini = self.x+self.bb.x+self.bb.w+4
|
||||
if self.x>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
|
||||
|
||||
Reference in New Issue
Block a user