Moguda la comprovació de pintar fora de la funció draw de cada actor
This commit is contained in:
@@ -49,7 +49,9 @@ end
|
|||||||
|
|
||||||
|
|
||||||
function abad_init()
|
function abad_init()
|
||||||
abad={ x=40, y=24,
|
abad={ name="abad",
|
||||||
|
x=40, y=24,
|
||||||
|
w=32, h=32,
|
||||||
flip=false,
|
flip=false,
|
||||||
frame=1,
|
frame=1,
|
||||||
wait=0,
|
wait=0,
|
||||||
@@ -265,7 +267,6 @@ function abad_land ()
|
|||||||
if can_land then
|
if can_land then
|
||||||
abad.jump_in_half_block_used = false
|
abad.jump_in_half_block_used = false
|
||||||
abad.jump_height = 0
|
abad.jump_height = 0
|
||||||
print("LANDED")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return can_land
|
return can_land
|
||||||
|
|||||||
@@ -25,11 +25,9 @@ function bol.draw()
|
|||||||
|
|
||||||
local x = bol_gif_col*tw
|
local x = bol_gif_col*tw
|
||||||
local y = toff+bol_gif_row*th
|
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 )
|
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)
|
draw.surf(x,y,bol.w,bol.h,scr_x,scr_y,bol.w,bol.h)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
function bol.update()
|
function bol.update()
|
||||||
-- if bol.hab==abad.hab then
|
-- if bol.hab==abad.hab then
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
type_shot={linear=1, rear=2, way3=3}
|
type_shot={linear=1, rear=2, way3=3}
|
||||||
|
|
||||||
cacau={
|
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 },
|
{ 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 },
|
||||||
{ 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 },
|
||||||
{ 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)
|
-- function cacau.init(_hab,_x,_y,_flip)
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ caco={}
|
|||||||
|
|
||||||
function caco.new(_hab,_x,_y,_flip)
|
function caco.new(_hab,_x,_y,_flip)
|
||||||
local world_x, world_y = coords.room_to_world(_hab,_x,_y)
|
local world_x, world_y = coords.room_to_world(_hab,_x,_y)
|
||||||
return {hab=_hab,
|
return {name="caco",
|
||||||
|
hab=_hab,
|
||||||
x=world_x,
|
x=world_x,
|
||||||
y=world_y,
|
y=world_y,
|
||||||
w=arcade_config.sprite_size.w,
|
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)*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 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 )
|
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)
|
draw.surf((self.frame&7)*cw, (self.frame>>cxr2)*ch, cw, ch, scr_x, scr_y, cw, ch, self.flip)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ cxr2 = arcade_config.character_per_row_base2
|
|||||||
cw = arcade_config.character_width
|
cw = arcade_config.character_width
|
||||||
ch = arcade_config.character_height
|
ch = arcade_config.character_height
|
||||||
|
|
||||||
elalien={hab=66,
|
elalien={name="elalien",
|
||||||
|
hab=66,
|
||||||
x=24,
|
x=24,
|
||||||
y=24,
|
y=24,
|
||||||
w=32,
|
w=32,
|
||||||
@@ -50,13 +51,11 @@ function elalien.draw()
|
|||||||
end
|
end
|
||||||
-- draw.surf((elalien.frame&7)*cw,(elalien.frame>>cxr2)*ch,cw,ch,elalien.x*o2aX,elalien.y*o2aX,cw,ch,flip)
|
-- 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 scr_x, scr_y = viewp:screen_coords( elalien.x, elalien.y )
|
||||||
local x = (elalien.frame&7)*cw
|
local x = (elalien.frame&7)*cw
|
||||||
local y = (elalien.frame>>cxr2)*ch
|
local y = (elalien.frame>>cxr2)*ch
|
||||||
draw.surf(x,y,cw,ch,scr_x,scr_y,elalien.w,elalien.h,flip)
|
draw.surf(x,y,cw,ch,scr_x,scr_y,elalien.w,elalien.h,flip)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
function elalien.hit()
|
function elalien.hit()
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -210,8 +210,7 @@ function update_game()
|
|||||||
render_map(sf_mapa, tiles, vp_x, vp_y)
|
render_map(sf_mapa, tiles, vp_x, vp_y)
|
||||||
|
|
||||||
for key,actor in pairs(actors) do
|
for key,actor in pairs(actors) do
|
||||||
-- if actor.hab==hab then
|
if viewp:inside(actor.x, actor.y, actor.w, actor.h) then
|
||||||
if true then
|
|
||||||
actor:draw()
|
actor:draw()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ ch = arcade_config.character_height
|
|||||||
gorro_gif_col = 6
|
gorro_gif_col = 6
|
||||||
gorro_gif_row = 2
|
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()
|
function gorro.init()
|
||||||
local habs={{60,5},{4,5},{34,4},{62,7},{75,4}}
|
local habs={{60,5},{4,5},{34,4},{62,7},{75,4}}
|
||||||
@@ -31,11 +31,9 @@ function gorro.draw()
|
|||||||
|
|
||||||
local x = gorro_gif_col*cw
|
local x = gorro_gif_col*cw
|
||||||
local y = gorro_gif_row*ch
|
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 )
|
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)
|
draw.surf(x,y,gorro.w,gorro.h,scr_x,scr_y,gorro.w,gorro.h)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
function gorro.update()
|
function gorro.update()
|
||||||
-- if gorro.hab==abad.hab then
|
-- if gorro.hab==abad.hab then
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ function gota.new(_hab,_x,_y,_freq,_x_offset, _y_offset)
|
|||||||
_y_offset = _y_offset or 0
|
_y_offset = _y_offset or 0
|
||||||
world_x = world_x+_x_offset
|
world_x = world_x+_x_offset
|
||||||
world_y = world_y+_y_offset
|
world_y = world_y+_y_offset
|
||||||
return {hab=_hab,
|
return {name="gota",
|
||||||
|
hab=_hab,
|
||||||
ix=world_x,
|
ix=world_x,
|
||||||
iy=world_y,
|
iy=world_y,
|
||||||
x=world_x,
|
x=world_x,
|
||||||
@@ -39,14 +40,12 @@ end
|
|||||||
function gota:draw_normal()
|
function gota:draw_normal()
|
||||||
local x = gota_gif_col*cw
|
local x = gota_gif_col*cw
|
||||||
local y = gota_gif_row*ch
|
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 )
|
local scr_x, scr_y = viewp:screen_coords( self.x, self.y )
|
||||||
draw.surf(x,y,self.w,self.h,scr_x,scr_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 x_check = scr_x+self.bb.x+(self.bb.w/2)-1
|
||||||
-- local y_check = scr_y+self.bb.h
|
-- local y_check = scr_y+self.bb.h
|
||||||
-- draw.rectf(x_check,y_check,1,1,4)
|
-- draw.rectf(x_check,y_check,1,1,4)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
function gota:update_normal()
|
function gota:update_normal()
|
||||||
self.wait=self.wait+1
|
self.wait=self.wait+1
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ ch = arcade_config.character_height
|
|||||||
gps_gif_col = 7
|
gps_gif_col = 7
|
||||||
gps_gif_row = 3
|
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()
|
function gps.init()
|
||||||
local habs={{33,8},{13,4},{51,9},{50,4},{42,7}}
|
local habs={{33,8},{13,4},{51,9},{50,4},{42,7}}
|
||||||
@@ -32,11 +32,9 @@ function gps.draw()
|
|||||||
|
|
||||||
local x = gps_gif_col*cw
|
local x = gps_gif_col*cw
|
||||||
local y = gps_gif_row*ch
|
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 )
|
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)
|
draw.surf(x,y,gps.w,gps.h,scr_x,scr_y,gps.w,gps.h)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
function gps.update()
|
function gps.update()
|
||||||
--if gps.hab==abad.hab then
|
--if gps.hab==abad.hab then
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ ch = arcade_config.character_height
|
|||||||
peu_gif_col = 7
|
peu_gif_col = 7
|
||||||
peu_gif_row = 2
|
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()
|
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}}
|
local habs={{18,8},{16,2},{16,7},{15,5},{27,1},{27,10},{29,2},{38,8},{69,2},{79,3}}
|
||||||
@@ -32,11 +32,9 @@ function peu.draw()
|
|||||||
|
|
||||||
local x = peu_gif_col*cw
|
local x = peu_gif_col*cw
|
||||||
local y = peu_gif_row*ch
|
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 )
|
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)
|
draw.surf(x,y,peu.w,peu.h,scr_x,scr_y,peu.w,peu.h)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
function peu.update()
|
function peu.update()
|
||||||
-- if peu.hab==abad.hab then
|
-- if peu.hab==abad.hab then
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ cxr2 = arcade_config.character_per_row_base2
|
|||||||
cw = arcade_config.character_width
|
cw = arcade_config.character_width
|
||||||
ch = arcade_config.character_height
|
ch = arcade_config.character_height
|
||||||
|
|
||||||
premiere={hab=75,
|
premiere={name="premiere",
|
||||||
|
hab=75,
|
||||||
x=24,
|
x=24,
|
||||||
y=24,
|
y=24,
|
||||||
w=32,
|
w=32,
|
||||||
@@ -45,14 +46,12 @@ 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)*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)
|
-- 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 )
|
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)
|
-- 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 x = (premiere.frame&7)*cw
|
||||||
local y = (premiere.frame>>cxr2)*ch
|
local y = (premiere.frame>>cxr2)*ch
|
||||||
draw.surf(x,y,cw,ch,scr_x,scr_y,premiere.w,premiere.h,premiere.flip)
|
draw.surf(x,y,cw,ch,scr_x,scr_y,premiere.w,premiere.h,premiere.flip)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
function premiere.hit()
|
function premiere.hit()
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ zombie={}
|
|||||||
|
|
||||||
function zombie.new(_hab,_x,_y,_flip)
|
function zombie.new(_hab,_x,_y,_flip)
|
||||||
local world_x, world_y = coords.room_to_world(_hab,_x,_y)
|
local world_x, world_y = coords.room_to_world(_hab,_x,_y)
|
||||||
return {hab=_hab,
|
return {name="zombie",
|
||||||
|
hab=_hab,
|
||||||
x=world_x,
|
x=world_x,
|
||||||
y=world_y,
|
y=world_y,
|
||||||
w=arcade_config.sprite_size.w,
|
w=arcade_config.sprite_size.w,
|
||||||
@@ -26,7 +27,7 @@ end
|
|||||||
function zombie:draw()
|
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)*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 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 )
|
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)
|
draw.surf((self.frame&7)*cw, (self.frame>>cxr2)*ch, cw, ch, scr_x, scr_y, cw, ch, self.flip)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user