From d45c2fe0114e15b4843a2e16c858c887deb59835 Mon Sep 17 00:00:00 2001 From: JailGamer Date: Thu, 2 Apr 2026 22:14:21 +0200 Subject: [PATCH] =?UTF-8?q?-=20El=20foc=20ja=20fa=20mal=20-=20El=20abad=20?= =?UTF-8?q?ja=20no=20es=20invencible=20si=20entra=20en=20col=C2=B7lisi?= =?UTF-8?q?=C3=B3=20infinita?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/abad.lua | 3 ++- data/game.lua | 11 ++++++----- data/invisible.lua | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 6 deletions(-) create mode 100644 data/invisible.lua diff --git a/data/abad.lua b/data/abad.lua index c9792b8..29b4bb3 100644 --- a/data/abad.lua +++ b/data/abad.lua @@ -107,6 +107,7 @@ end function abad_hurt(howmuch) + print(abad.hurting.." / "..abad.respawning) if abad.hurting == 0 and abad.respawning==0 then sound.play(audio_abad_hit) abad.energia=abad.energia-howmuch @@ -136,7 +137,7 @@ function abad_hurt(howmuch) surf.cls(3) end end - abad.respawning = 120 + if abad.respawning==0 then abad.respawning = 120 end end function abad_do_jump ( jumpfwd ) diff --git a/data/game.lua b/data/game.lua index 4d483e8..f6a292e 100644 --- a/data/game.lua +++ b/data/game.lua @@ -8,6 +8,7 @@ require "premiere" require "elalien" require "bol" require "gota" +require "invisible" require "caco" require "zombie" require "score" @@ -130,10 +131,10 @@ print("GAME INIT") table.insert( actors, gota.new(77,9,1,25,-5,-7) ) -- FOC? - -- table.insert(actors,invisible.new(77,40,32)) - -- table.insert(actors,invisible.new(77,48,32)) - -- table.insert(actors,invisible.new(58,16,32)) - -- table.insert(actors,invisible.new(58,16,32)) + table.insert(actors,invisible.new(77,5,4)) + table.insert(actors,invisible.new(77,6,4)) + table.insert(actors,invisible.new(58,2,4)) + table.insert(actors,invisible.new(58,3,4)) table.insert( actors, caco.new(13,3,2,true ) ) 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) end 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) abad:move(abad_x, abad_y) local scr_ax, scr_ay = viewp:screen_coords(abad_x, abad_y) diff --git a/data/invisible.lua b/data/invisible.lua new file mode 100644 index 0000000..fe9837f --- /dev/null +++ b/data/invisible.lua @@ -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