Moguda la comprovació de pintar fora de la funció draw de cada actor

This commit is contained in:
2026-03-29 17:02:05 +02:00
parent 2c93003fe2
commit 7f4f29ecc2
12 changed files with 44 additions and 53 deletions

View File

@@ -49,7 +49,9 @@ end
function abad_init()
abad={ x=40, y=24,
abad={ name="abad",
x=40, y=24,
w=32, h=32,
flip=false,
frame=1,
wait=0,
@@ -265,7 +267,6 @@ function abad_land ()
if can_land then
abad.jump_in_half_block_used = false
abad.jump_height = 0
print("LANDED")
end
return can_land

View File

@@ -25,10 +25,8 @@ function bol.draw()
local x = bol_gif_col*tw
local y = toff+bol_gif_row*th
if viewp:inside(bol.x, bol.y, bol.w, bol.h) then
local scr_x, scr_y = viewp:screen_coords( bol.x, bol.y )
draw.surf(x,y,bol.w,bol.h,scr_x,scr_y,bol.w,bol.h)
end
end
function bol.update()

View File

@@ -3,9 +3,9 @@
type_shot={linear=1, rear=2, way3=3}
cacau={
{ hab=-1, x=0, y=0, w=12 ,h=8 ,wait=0, flip=false, bb={x=0,y=0,w=4,h=4}, alive=false, power=1 },
{ hab=-1, x=0, y=0, w=12 ,h=8 ,wait=0, flip=false, bb={x=0,y=0,w=4,h=4}, alive=false, power=1 },
{ hab=-1, x=0, y=0, w=12 ,h=8 ,wait=0, flip=false, bb={x=0,y=0,w=4,h=4}, alive=false, power=1 }
{ name="cacau1", hab=-1, x=0, y=0, w=12 ,h=8 ,wait=0, flip=false, bb={x=0,y=0,w=4,h=4}, alive=false, power=1 },
{ name="cacau2", hab=-1, x=0, y=0, w=12 ,h=8 ,wait=0, flip=false, bb={x=0,y=0,w=4,h=4}, alive=false, power=1 },
{ name="cacau3", hab=-1, x=0, y=0, w=12 ,h=8 ,wait=0, flip=false, bb={x=0,y=0,w=4,h=4}, alive=false, power=1 }
}
-- function cacau.init(_hab,_x,_y,_flip)

View File

@@ -8,7 +8,8 @@ caco={}
function caco.new(_hab,_x,_y,_flip)
local world_x, world_y = coords.room_to_world(_hab,_x,_y)
return {hab=_hab,
return {name="caco",
hab=_hab,
x=world_x,
y=world_y,
w=arcade_config.sprite_size.w,
@@ -29,7 +30,7 @@ function caco:draw()
-- if self.frame>0 then draw.surf((self.frame&7)*16,(self.frame>>3)*16,16,16,self.x,self.y,16,16,self.flip) end
-- if self.frame>0 then draw.surf((self.frame&7)*cw,(self.frame>>cxr2)*ch,cw,ch,self.x*o2aX,self.y*o2aX,cw,ch,self.flip) end
if self.frame>0 and viewp:inside(self.x, self.y, self.w, self.h) then
if self.frame>0 then
local scr_x, scr_y = viewp:screen_coords( self.x, self.y )
draw.surf((self.frame&7)*cw, (self.frame>>cxr2)*ch, cw, ch, scr_x, scr_y, cw, ch, self.flip)
end

View File

@@ -4,7 +4,8 @@ cxr2 = arcade_config.character_per_row_base2
cw = arcade_config.character_width
ch = arcade_config.character_height
elalien={hab=66,
elalien={name="elalien",
hab=66,
x=24,
y=24,
w=32,
@@ -50,12 +51,10 @@ function elalien.draw()
end
-- draw.surf((elalien.frame&7)*cw,(elalien.frame>>cxr2)*ch,cw,ch,elalien.x*o2aX,elalien.y*o2aX,cw,ch,flip)
if viewp:inside(elalien.x, elalien.y, elalien.w, elalien.h) then
local scr_x, scr_y = viewp:screen_coords( elalien.x, elalien.y )
local x = (elalien.frame&7)*cw
local y = (elalien.frame>>cxr2)*ch
draw.surf(x,y,cw,ch,scr_x,scr_y,elalien.w,elalien.h,flip)
end
end
function elalien.hit()

View File

@@ -210,8 +210,7 @@ function update_game()
render_map(sf_mapa, tiles, vp_x, vp_y)
for key,actor in pairs(actors) do
-- if actor.hab==hab then
if true then
if viewp:inside(actor.x, actor.y, actor.w, actor.h) then
actor:draw()
end
end

View File

@@ -7,7 +7,7 @@ ch = arcade_config.character_height
gorro_gif_col = 6
gorro_gif_row = 2
gorro={hab=5,x=6,y=3,w=32,h=32,bb={x=0,y=0,w=16,h=16}}
gorro={name="gorro",hab=5,x=6,y=3,w=32,h=32,bb={x=0,y=0,w=16,h=16}}
function gorro.init()
local habs={{60,5},{4,5},{34,4},{62,7},{75,4}}
@@ -31,10 +31,8 @@ function gorro.draw()
local x = gorro_gif_col*cw
local y = gorro_gif_row*ch
if viewp:inside(gorro.x, gorro.y, gorro.w, gorro.h) then
local scr_x, scr_y = viewp:screen_coords( gorro.x, gorro.y )
draw.surf(x,y,gorro.w,gorro.h,scr_x,scr_y,gorro.w,gorro.h)
end
end
function gorro.update()

View File

@@ -15,7 +15,8 @@ function gota.new(_hab,_x,_y,_freq,_x_offset, _y_offset)
_y_offset = _y_offset or 0
world_x = world_x+_x_offset
world_y = world_y+_y_offset
return {hab=_hab,
return {name="gota",
hab=_hab,
ix=world_x,
iy=world_y,
x=world_x,
@@ -39,13 +40,11 @@ end
function gota:draw_normal()
local x = gota_gif_col*cw
local y = gota_gif_row*ch
if viewp:inside(self.x, self.y, self.w, self.h) then
local scr_x, scr_y = viewp:screen_coords( self.x, self.y )
draw.surf(x,y,self.w,self.h,scr_x,scr_y)
-- local x_check = scr_x+self.bb.x+(self.bb.w/2)-1
-- local y_check = scr_y+self.bb.h
-- draw.rectf(x_check,y_check,1,1,4)
end
end
function gota:update_normal()

View File

@@ -7,7 +7,7 @@ ch = arcade_config.character_height
gps_gif_col = 7
gps_gif_row = 3
gps={hab=5,x=6,y=3,w=32,h=32,bb={x=0,y=0,w=16,h=16}}
gps={name="gps",hab=5,x=6,y=3,w=32,h=32,bb={x=0,y=0,w=16,h=16}}
function gps.init()
local habs={{33,8},{13,4},{51,9},{50,4},{42,7}}
@@ -32,10 +32,8 @@ function gps.draw()
local x = gps_gif_col*cw
local y = gps_gif_row*ch
if viewp:inside(gps.x, gps.y, gps.w, gps.h) then
local scr_x, scr_y = viewp:screen_coords( gps.x, gps.y )
draw.surf(x,y,gps.w,gps.h,scr_x,scr_y,gps.w,gps.h)
end
end
function gps.update()

View File

@@ -7,7 +7,7 @@ ch = arcade_config.character_height
peu_gif_col = 7
peu_gif_row = 2
peu={hab=5,x=6,y=3,w=32,h=32,bb={x=0,y=0,w=16,h=16}}
peu={name="peu",hab=5,x=6,y=3,w=32,h=32,bb={x=0,y=0,w=16,h=16}}
function peu.init()
local habs={{18,8},{16,2},{16,7},{15,5},{27,1},{27,10},{29,2},{38,8},{69,2},{79,3}}
@@ -32,10 +32,8 @@ function peu.draw()
local x = peu_gif_col*cw
local y = peu_gif_row*ch
if viewp:inside(peu.x, peu.y, peu.w, peu.h) then
local scr_x, scr_y = viewp:screen_coords( peu.x, peu.y )
draw.surf(x,y,peu.w,peu.h,scr_x,scr_y,peu.w,peu.h)
end
end
function peu.update()

View File

@@ -4,7 +4,8 @@ cxr2 = arcade_config.character_per_row_base2
cw = arcade_config.character_width
ch = arcade_config.character_height
premiere={hab=75,
premiere={name="premiere",
hab=75,
x=24,
y=24,
w=32,
@@ -45,13 +46,11 @@ function premiere.draw()
-- draw.surf((premiere.frame&7)*16,(premiere.frame>>3)*16,16,16,premiere.x,premiere.y,16,16,premiere.flip)
-- draw.surf((premiere.frame&7)*cw,(premiere.frame>>cxr2)*ch,cw,ch,premiere.x*o2aX,premiere.y*o2aX,cw,ch,premiere.flip)
if viewp:inside(premiere.x, premiere.y, premiere.w, premiere.h) then
local scr_x, scr_y = viewp:screen_coords( premiere.x, premiere.y )
-- draw.surf(premiere.x,premiere.y,premiere.w,premiere.h,scr_x,scr_y,premiere.w,premiere.h)
local x = (premiere.frame&7)*cw
local y = (premiere.frame>>cxr2)*ch
draw.surf(x,y,cw,ch,scr_x,scr_y,premiere.w,premiere.h,premiere.flip)
end
end
function premiere.hit()

View File

@@ -6,7 +6,8 @@ zombie={}
function zombie.new(_hab,_x,_y,_flip)
local world_x, world_y = coords.room_to_world(_hab,_x,_y)
return {hab=_hab,
return {name="zombie",
hab=_hab,
x=world_x,
y=world_y,
w=arcade_config.sprite_size.w,
@@ -26,7 +27,7 @@ end
function zombie:draw()
-- if self.frame>0 then draw.surf((self.frame&7)*16,(self.frame>>3)*16,16,16,self.x,self.y,16,16,self.flip) end
-- if self.frame>0 then draw.surf((self.frame&7)*cw,(self.frame>>cxr2)*ch,cw,ch,self.x*o2aX,self.y*o2aX,cw,ch,self.flip) end
if self.frame>0 and viewp:inside(self.x, self.y, self.w, self.h) then
if self.frame>0 then
local scr_x, scr_y = viewp:screen_coords( self.x, self.y )
draw.surf((self.frame&7)*cw, (self.frame>>cxr2)*ch, cw, ch, scr_x, scr_y, cw, ch, self.flip)
end