- El foc ja fa mal
- El abad ja no es invencible si entra en col·lisió infinita
This commit is contained in:
@@ -107,6 +107,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
function abad_hurt(howmuch)
|
function abad_hurt(howmuch)
|
||||||
|
print(abad.hurting.." / "..abad.respawning)
|
||||||
if abad.hurting == 0 and abad.respawning==0 then
|
if abad.hurting == 0 and abad.respawning==0 then
|
||||||
sound.play(audio_abad_hit)
|
sound.play(audio_abad_hit)
|
||||||
abad.energia=abad.energia-howmuch
|
abad.energia=abad.energia-howmuch
|
||||||
@@ -136,7 +137,7 @@ function abad_hurt(howmuch)
|
|||||||
surf.cls(3)
|
surf.cls(3)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
abad.respawning = 120
|
if abad.respawning==0 then abad.respawning = 120 end
|
||||||
end
|
end
|
||||||
|
|
||||||
function abad_do_jump ( jumpfwd )
|
function abad_do_jump ( jumpfwd )
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ require "premiere"
|
|||||||
require "elalien"
|
require "elalien"
|
||||||
require "bol"
|
require "bol"
|
||||||
require "gota"
|
require "gota"
|
||||||
|
require "invisible"
|
||||||
require "caco"
|
require "caco"
|
||||||
require "zombie"
|
require "zombie"
|
||||||
require "score"
|
require "score"
|
||||||
@@ -130,10 +131,10 @@ print("GAME INIT")
|
|||||||
table.insert( actors, gota.new(77,9,1,25,-5,-7) )
|
table.insert( actors, gota.new(77,9,1,25,-5,-7) )
|
||||||
|
|
||||||
-- FOC?
|
-- FOC?
|
||||||
-- table.insert(actors,invisible.new(77,40,32))
|
table.insert(actors,invisible.new(77,5,4))
|
||||||
-- table.insert(actors,invisible.new(77,48,32))
|
table.insert(actors,invisible.new(77,6,4))
|
||||||
-- table.insert(actors,invisible.new(58,16,32))
|
table.insert(actors,invisible.new(58,2,4))
|
||||||
-- table.insert(actors,invisible.new(58,16,32))
|
table.insert(actors,invisible.new(58,3,4))
|
||||||
|
|
||||||
table.insert( actors, caco.new(13,3,2,true ) )
|
table.insert( actors, caco.new(13,3,2,true ) )
|
||||||
table.insert( actors, caco.new(17,3,2,false) )
|
table.insert( actors, caco.new(17,3,2,false) )
|
||||||
@@ -259,7 +260,7 @@ function update_game()
|
|||||||
local scr_ax, scr_ay = viewp:screen_coords(abad_x, abad_y)
|
local scr_ax, scr_ay = viewp:screen_coords(abad_x, abad_y)
|
||||||
end
|
end
|
||||||
if key.press(key.N0) then
|
if key.press(key.N0) then
|
||||||
local abad_x, abad_y = coords.room_to_world ( 24, 1, 3 )
|
local abad_x, abad_y = coords.room_to_world ( 58, 3, 3 )
|
||||||
print(abad_x..", "..abad_y)
|
print(abad_x..", "..abad_y)
|
||||||
abad:move(abad_x, abad_y)
|
abad:move(abad_x, abad_y)
|
||||||
local scr_ax, scr_ay = viewp:screen_coords(abad_x, abad_y)
|
local scr_ax, scr_ay = viewp:screen_coords(abad_x, abad_y)
|
||||||
|
|||||||
46
data/invisible.lua
Normal file
46
data/invisible.lua
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
invisible={}
|
||||||
|
|
||||||
|
function invisible.new(_hab,_x,_y)
|
||||||
|
local world_x, world_y = coords.room_to_world(_hab,_x,_y)
|
||||||
|
return {hab=_hab,
|
||||||
|
x=world_x,
|
||||||
|
y=world_y,
|
||||||
|
w=16,
|
||||||
|
h=16,
|
||||||
|
wait=0,
|
||||||
|
hit=invisible.hit,
|
||||||
|
update=invisible.update,
|
||||||
|
draw=invisible.draw,
|
||||||
|
bb={x=0,y=0,w=16,h=16}}
|
||||||
|
end
|
||||||
|
|
||||||
|
function invisible:draw()
|
||||||
|
-- Es invisible, res que drawar
|
||||||
|
-- local scr_x, scr_y = viewp:screen_coords( self.x, self.y )
|
||||||
|
-- draw.rectf(scr_x, scr_y, 16, 8, 2)
|
||||||
|
end
|
||||||
|
|
||||||
|
function invisible:update()
|
||||||
|
--self.wait=self.wait+1
|
||||||
|
--
|
||||||
|
--if self.wait==6 then
|
||||||
|
-- self.wait=0
|
||||||
|
--
|
||||||
|
-- if self.hab==abad.hab then
|
||||||
|
-- if aabb(abad,self) then
|
||||||
|
-- abad_hurt(1)
|
||||||
|
-- end
|
||||||
|
-- end
|
||||||
|
--
|
||||||
|
--end
|
||||||
|
|
||||||
|
if viewp:inside(self.x, self.y, self.w, self.h) then
|
||||||
|
if collision(abad,self) then
|
||||||
|
print("check collision")
|
||||||
|
abad_hurt(1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function invisible:hit()
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user