[NEW] Botella de vida
This commit is contained in:
@@ -118,7 +118,7 @@ function abad:draw()
|
|||||||
abad.respawning=abad.respawning-1
|
abad.respawning=abad.respawning-1
|
||||||
end
|
end
|
||||||
|
|
||||||
draw.rect(x+abad.bb.x,y+abad.bb.y,abad.bb.w,abad.bb.h,3)
|
-- draw.rect(x+abad.bb.x,y+abad.bb.y,abad.bb.w,abad.bb.h,3)
|
||||||
end
|
end
|
||||||
|
|
||||||
function abad_make_safe( force )
|
function abad_make_safe( force )
|
||||||
@@ -131,6 +131,12 @@ function abad_make_safe( force )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function abad_heal(howmuch)
|
||||||
|
abad.energia = abad.energia + howmuch
|
||||||
|
if abad.energia>abad.max_energia then
|
||||||
|
abad.energia = abad.max_energia
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function abad_hurt(howmuch)
|
function abad_hurt(howmuch)
|
||||||
-- howmuch = 0
|
-- howmuch = 0
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ require "dialeg"
|
|||||||
require "trigger_event"
|
require "trigger_event"
|
||||||
|
|
||||||
require "batman"
|
require "batman"
|
||||||
|
require "health_potion"
|
||||||
|
|
||||||
local DEBUG = false
|
local DEBUG = false
|
||||||
|
|
||||||
@@ -208,6 +209,8 @@ function world_update()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
health_potion.update()
|
||||||
|
|
||||||
if stages.boss_loaded then
|
if stages.boss_loaded then
|
||||||
stage_update()
|
stage_update()
|
||||||
else
|
else
|
||||||
@@ -244,6 +247,7 @@ function world_draw()
|
|||||||
end
|
end
|
||||||
|
|
||||||
dialeg.draw()
|
dialeg.draw()
|
||||||
|
health_potion.draw()
|
||||||
|
|
||||||
if stages.boss_loaded then stage_draw_middle() end
|
if stages.boss_loaded then stage_draw_middle() end
|
||||||
|
|
||||||
|
|||||||
81
data/health_potion.lua
Normal file
81
data/health_potion.lua
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
-- posició en el gif (tiles de 32)
|
||||||
|
health_potion_gif_x = 192
|
||||||
|
health_potion_gif_y = 128
|
||||||
|
|
||||||
|
health_potion={
|
||||||
|
name="health_potion",
|
||||||
|
hab=1,
|
||||||
|
x=1,y=1,
|
||||||
|
vx=0, vy=0,
|
||||||
|
w=16,h=16,
|
||||||
|
y_speed=1,
|
||||||
|
max_height=16,
|
||||||
|
heal = 2,
|
||||||
|
raising=false,
|
||||||
|
enabled=false,
|
||||||
|
wait = 0,
|
||||||
|
bb={x=4,y=0,w=9,h=16}
|
||||||
|
}
|
||||||
|
|
||||||
|
function health_potion.init(hab, x, y, y_speed, max_height, heal)
|
||||||
|
health_potion.hab = hab
|
||||||
|
health_potion.x = x
|
||||||
|
health_potion.y = y
|
||||||
|
health_potion.y_speed = y_speed
|
||||||
|
health_potion.max_height = max_height
|
||||||
|
health_potion.heal = heal
|
||||||
|
if max_height>0 then health_potion.raising=true end
|
||||||
|
|
||||||
|
--local world_x, world_y = coords.room_to_world(health_potion.hab,health_potion.x,health_potion.y)
|
||||||
|
--health_potion.x=world_x
|
||||||
|
--health_potion.y=world_y
|
||||||
|
|
||||||
|
health_potion.update=health_potion.update
|
||||||
|
health_potion.draw=health_potion.draw
|
||||||
|
health_potion.enabled=true
|
||||||
|
end
|
||||||
|
|
||||||
|
function health_potion.draw()
|
||||||
|
if not health_potion.enabled then return end
|
||||||
|
local x = health_potion_gif_x
|
||||||
|
local y = health_potion_gif_y
|
||||||
|
local scr_x, scr_y = viewp:screen_coords( health_potion.x, health_potion.y )
|
||||||
|
draw.surf(x,y,health_potion.w,health_potion.h,scr_x,scr_y,health_potion.w,health_potion.h)
|
||||||
|
-- draw.rect(scr_x+health_potion.bb.x,scr_y+health_potion.bb.y,health_potion.bb.w,health_potion.bb.h,3)
|
||||||
|
end
|
||||||
|
|
||||||
|
function health_potion.update()
|
||||||
|
if not health_potion.enabled then return end
|
||||||
|
if health_potion.raising and health_potion.y_speed>0 then
|
||||||
|
health_potion.y_speed = -health_potion.y_speed
|
||||||
|
elseif not health_potion.raising and health_potion.y_speed<0 then
|
||||||
|
health_potion.y_speed = -health_potion.y_speed
|
||||||
|
end
|
||||||
|
|
||||||
|
local x2_check = health_potion.x+health_potion.bb.x+health_potion.bb.w
|
||||||
|
local x1_check = health_potion.x+health_potion.bb.x
|
||||||
|
local y_check = health_potion.y+health_potion.bb.h+health_potion.y_speed
|
||||||
|
|
||||||
|
if true then
|
||||||
|
health_potion.wait=0
|
||||||
|
health_potion.max_height = health_potion.max_height+health_potion.y_speed
|
||||||
|
health_potion.y = health_potion.y+health_potion.y_speed
|
||||||
|
if health_potion.max_height==0 then health_potion.raising=false end
|
||||||
|
end
|
||||||
|
health_potion.wait=health_potion.wait+1
|
||||||
|
|
||||||
|
local tile1_hit_type= arc_check_tile(x1_check, y_check )
|
||||||
|
local tile2_hit_type= arc_check_tile(x2_check, y_check)
|
||||||
|
local block_tile = tile1_hit_type == tiletype.block or tile2_hit_type == tiletype.block
|
||||||
|
|
||||||
|
if block_tile then health_potion.y_speed=0 end
|
||||||
|
health_potion.hab = coords.world_to_tile(health_potion.x, health_potion.y)
|
||||||
|
if health_potion.hab==abad.hab then
|
||||||
|
if collision(abad,health_potion) then
|
||||||
|
-- abad.objects.health_potion=true
|
||||||
|
-- remove_actor(health_potion)
|
||||||
|
abad_heal(health_potion.heal)
|
||||||
|
health_potion.enabled = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -64,7 +64,7 @@ function trigger:draw()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- debug rect
|
-- debug rect
|
||||||
draw.rect(scr_x,scr_y,self.bb.w,self.bb.h,3)
|
-- draw.rect(scr_x,scr_y,self.bb.w,self.bb.h,3)
|
||||||
end
|
end
|
||||||
|
|
||||||
--function trigger:do_touched()
|
--function trigger:do_touched()
|
||||||
|
|||||||
@@ -104,6 +104,10 @@ function trigger_ev:premiere_healer_update()
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
premiere.health_wait = premiere.health_wait - 1
|
premiere.health_wait = premiere.health_wait - 1
|
||||||
|
health_potion.init(premiere.hab,
|
||||||
|
premiere.x+premiere.bb.x+premiere.bb.w,
|
||||||
|
premiere.y+premiere.bb.y+premiere.bb.h/3,
|
||||||
|
1, 24, 2)
|
||||||
elseif hab >= 56 then
|
elseif hab >= 56 then
|
||||||
-- Restaurar a Premiere
|
-- Restaurar a Premiere
|
||||||
premiere.hab = premiere.from_hab
|
premiere.hab = premiere.from_hab
|
||||||
|
|||||||
Reference in New Issue
Block a user