From 8d84cdbda1b639d24c94af3b457a9c2499009ef7 Mon Sep 17 00:00:00 2001 From: JailGamer Date: Sun, 29 Mar 2026 19:32:13 +0200 Subject: [PATCH] El monstruitos ja fan pupa --- data/abad.lua | 1 + data/caco.lua | 7 ++++++- data/game.lua | 14 ++++++-------- data/gota.lua | 11 +++++++++++ data/zombie.lua | 6 ++++++ 5 files changed, 30 insertions(+), 9 deletions(-) diff --git a/data/abad.lua b/data/abad.lua index 0b55b5b..c9792b8 100644 --- a/data/abad.lua +++ b/data/abad.lua @@ -136,6 +136,7 @@ function abad_hurt(howmuch) surf.cls(3) end end + abad.respawning = 120 end function abad_do_jump ( jumpfwd ) diff --git a/data/caco.lua b/data/caco.lua index 4b6cfb4..a8a5591 100644 --- a/data/caco.lua +++ b/data/caco.lua @@ -73,7 +73,12 @@ function caco:update_normal() self.flip=not self.flip end - + if viewp:inside(self.x, self.y, self.w, self.h) then + if collision(abad,self) then + abad_hurt(1) + end + end + -- if self.hab==abad.hab then -- if aabb(abad,self) then -- abad_hurt(1) diff --git a/data/game.lua b/data/game.lua index 5054284..f22a1b4 100644 --- a/data/game.lua +++ b/data/game.lua @@ -175,16 +175,11 @@ function update_game() arc_mapa_update() + -- Moure a tots for key,actor in pairs(actors) do actor:update() - --if actor.hab==cacau.hab and actor~=abad then - -- if aabb(actor,cacau) then - -- if actor.hit~=nil then - -- actor:hit() - -- cacau.hab=-1 - -- end - -- end - --end + + -- Comprovar dispars contra "monstres" if viewp:inside(actor.x, actor.y, actor.w, actor.h) and actor~=abad then for _, cacau_shot in pairs(cacau.shots()) do if cacau_shot.alive and collision(actor,cacau_shot) then @@ -200,6 +195,7 @@ function update_game() cacau.update() switches.update() + -- Moure el viewport local vp_x = viewp.x local vp_y = viewp.y --viewp:position(vp_x, vp_y) @@ -214,6 +210,8 @@ function update_game() if vp_y < 0 then vp_y = 0 end viewp:position(vp_x, vp_y) + + -- Pintar la finestra del mon render_map(sf_mapa, tiles, vp_x, vp_y) for key,actor in pairs(actors) do diff --git a/data/gota.lua b/data/gota.lua index f7a427b..c891277 100644 --- a/data/gota.lua +++ b/data/gota.lua @@ -74,6 +74,17 @@ function gota:update_normal() --self.flip=not self.flip end + if viewp:inside(self.x, self.y, self.w, self.h) then + if collision(abad,self) then + abad_hurt(1) + self.update=gota.update_splash + self.draw=gota.draw_splash + self.cx=self.x+2 + self.dx=0 + self.dy=-4 + end + end + -- if self.hab==abad.hab then -- if aabb(abad,self) then -- abad_hurt(1) diff --git a/data/zombie.lua b/data/zombie.lua index 906094e..e47441f 100644 --- a/data/zombie.lua +++ b/data/zombie.lua @@ -62,6 +62,12 @@ function zombie:update_normal() self.flip=not self.flip end + if viewp:inside(self.x, self.y, self.w, self.h) then + if collision(abad,self) then + abad_hurt(1) + end + end + -- if self.hab==abad.hab then -- if aabb(abad,self) then -- abad_hurt(1)