Compare commits
3 Commits
40ea0786c2
...
fa74a841e7
| Author | SHA1 | Date | |
|---|---|---|---|
| fa74a841e7 | |||
| 7f4f29ecc2 | |||
| 2c93003fe2 |
@@ -29,27 +29,10 @@ abad={}
|
||||
function abad_nop()
|
||||
end
|
||||
|
||||
-- Imprime cualquier valor, incluyendo tablas anidadas
|
||||
local function dump(value, indent)
|
||||
indent = indent or ""
|
||||
if type(value) ~= "table" then
|
||||
return tostring(value)
|
||||
end
|
||||
|
||||
local parts = {"{"}
|
||||
for k, v in pairs(value) do
|
||||
local key = (type(k) == "string") and k or "["..tostring(k).."]"
|
||||
table.insert(parts,
|
||||
string.format("%s %s = %s,",
|
||||
indent, key, dump(v, indent.." ")))
|
||||
end
|
||||
table.insert(parts, indent.."}")
|
||||
return table.concat(parts, "\n")
|
||||
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,
|
||||
@@ -211,8 +194,8 @@ function abad_jump()
|
||||
else
|
||||
local tile1_hit = arc_get_tile(x1_check, y_check )
|
||||
local tile2_hit = arc_get_tile(x2_check, y_check)
|
||||
local half_block1 = mapa_is_half_block_tile(tile1_hit)
|
||||
local half_block2 = mapa_is_half_block_tile(tile2_hit)
|
||||
local half_block1 = mapa_is_half_block_tile(map_to_editor_tile(tile1_hit))
|
||||
local half_block2 = mapa_is_half_block_tile(map_to_editor_tile(tile2_hit))
|
||||
local full_block1 = tile1_hit_type == tiletype.block and not half_block1
|
||||
local full_block2 = tile2_hit_type == tiletype.block and not half_block2
|
||||
local full_block = full_block1 and full_block2
|
||||
@@ -232,7 +215,8 @@ function abad_jump()
|
||||
-- permetre continuar en el salt
|
||||
if not full_block and half_block then
|
||||
if abad.jump_in_half_block==0 and not abad.jump_in_half_block_used then
|
||||
abad.jump_in_half_block = arcade_config.tiles_height>>1
|
||||
abad.jump_in_half_block = arcade_config.tiles_height / 2
|
||||
-- print(abad.jump_in_half_block)
|
||||
end
|
||||
if abad.jump_in_half_block>0 then
|
||||
abad.y=abad.y-vspace
|
||||
|
||||
@@ -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
|
||||
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
|
||||
|
||||
function bol.update()
|
||||
|
||||
@@ -3,9 +3,11 @@
|
||||
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 }
|
||||
shot={
|
||||
{ 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)
|
||||
@@ -17,15 +19,20 @@ cacau={
|
||||
-- cacau.alive = true
|
||||
-- end
|
||||
|
||||
function cacau.shots()
|
||||
-- print(cacau[1].name)
|
||||
return cacau.shot
|
||||
end
|
||||
|
||||
function cacau.init(_x,_y,_flip,_power,_num_shots,_type_shot)
|
||||
if _type_shot==type_shot.linear then
|
||||
for ns=1,_num_shots do
|
||||
if cacau[ns].alive == true then break end
|
||||
cacau[ns].x=_x
|
||||
cacau[ns].y=_y
|
||||
cacau[ns].flip=_flip
|
||||
cacau[ns].alive = true
|
||||
cacau[ns].power = _power
|
||||
if cacau.shot[ns].alive == true then break end
|
||||
cacau.shot[ns].x=_x
|
||||
cacau.shot[ns].y=_y
|
||||
cacau.shot[ns].flip=_flip
|
||||
cacau.shot[ns].alive = true
|
||||
cacau.shot[ns].power = _power
|
||||
end
|
||||
elseif _type_shot==type_shot.rear then
|
||||
|
||||
@@ -38,7 +45,7 @@ function cacau:available(_num_shots,_type_shot)
|
||||
local avail_shots = false
|
||||
if _type_shot==type_shot.linear then
|
||||
for ns=1,_num_shots do
|
||||
if cacau[ns].alive == false then avail_shots = true end
|
||||
if cacau.shot[ns].alive == false then avail_shots = true end
|
||||
end
|
||||
elseif _type_shot==type_shot.rear then
|
||||
|
||||
@@ -49,10 +56,14 @@ function cacau:available(_num_shots,_type_shot)
|
||||
return avail_shots
|
||||
end
|
||||
|
||||
function cacau:kill(shot)
|
||||
shot.alive = false
|
||||
end
|
||||
|
||||
function cacau.draw()
|
||||
for ns=1,3 do
|
||||
if cacau[ns].alive==true then
|
||||
local cx, cy = viewp:screen_coords(cacau[ns].x, cacau[ns].y)
|
||||
if cacau.shot[ns].alive==true then
|
||||
local cx, cy = viewp:screen_coords(cacau.shot[ns].x, cacau.shot[ns].y)
|
||||
draw.circf( cx, cy, 4,16)
|
||||
draw.circf( cx+4, cy, 4,16)
|
||||
draw.circf( cx , cy, 2,6)
|
||||
@@ -63,30 +74,30 @@ end
|
||||
|
||||
function cacau.update()
|
||||
for ns=1,3 do
|
||||
if cacau[ns].alive==true then
|
||||
if viewp:inside(cacau[ns].x, cacau[ns].y, cacau[ns].w, cacau[ns].h)==false then
|
||||
cacau[ns].hab=-1
|
||||
cacau[ns].alive=false
|
||||
if cacau.shot[ns].alive==true then
|
||||
if viewp:inside(cacau.shot[ns].x, cacau.shot[ns].y, cacau.shot[ns].w, cacau.shot[ns].h)==false then
|
||||
cacau.shot[ns].hab=-1
|
||||
cacau.shot[ns].alive=false
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
cacau[ns].wait=cacau[ns].wait+1
|
||||
cacau.shot[ns].wait=cacau.shot[ns].wait+1
|
||||
|
||||
if cacau[ns].wait == 3 then cacau[ns].wait = 0 end
|
||||
if cacau.shot[ns].wait == 3 then cacau.shot[ns].wait = 0 end
|
||||
|
||||
if arc_check_tile(cacau[ns].x,cacau[ns].y)<tiletype.block then
|
||||
if arc_check_tile(cacau.shot[ns].x,cacau.shot[ns].y)<tiletype.block then
|
||||
local step=3
|
||||
if cacau[ns].flip then step=-step end
|
||||
cacau[ns].x=cacau[ns].x+step
|
||||
if cacau.shot[ns].flip then step=-step end
|
||||
cacau.shot[ns].x=cacau.shot[ns].x+step
|
||||
|
||||
if viewp:inside(cacau[ns].x, cacau[ns].y, cacau[ns].w, cacau[ns].h)==false then
|
||||
cacau[ns].alive=false
|
||||
if viewp:inside(cacau.shot[ns].x, cacau.shot[ns].y, cacau.shot[ns].w, cacau.shot[ns].h)==false then
|
||||
cacau.shot[ns].alive=false
|
||||
break
|
||||
end
|
||||
else
|
||||
cacau[ns].hab=-1
|
||||
cacau[ns].alive = false
|
||||
cacau.shot[ns].hab=-1
|
||||
cacau.shot[ns].alive = false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
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
|
||||
|
||||
function elalien.hit()
|
||||
|
||||
134
data/game.lua
134
data/game.lua
@@ -1,8 +1,4 @@
|
||||
arcade_config = require("arcade_config")
|
||||
viewport= require("viewport")
|
||||
|
||||
require "fps"
|
||||
require "mapa"
|
||||
require "abad"
|
||||
require "cacau"
|
||||
require "caco"
|
||||
@@ -189,7 +185,18 @@ function update_game()
|
||||
-- end
|
||||
-- end
|
||||
--end
|
||||
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
|
||||
if actor.hit ~= nil then
|
||||
actor:hit()
|
||||
cacau:kill(cacau_shot)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
cacau.update()
|
||||
switches.update()
|
||||
|
||||
@@ -210,8 +217,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
|
||||
@@ -220,88 +226,56 @@ function update_game()
|
||||
score.draw()
|
||||
|
||||
fps_print()
|
||||
viewp:print()
|
||||
msg_print(0,14,"ABAD= "..abad.x..", "..abad.y, true)
|
||||
msg_print(0,21,"VIEW= "..vp_x..", "..vp_y, true)
|
||||
local hab, xx, yy = coords.world_to_tile(abad.x, abad.y)
|
||||
msg_print(0,28,hab.." ( "..xx..", "..yy.." )", true)
|
||||
-- viewp:print()
|
||||
-- msg_print(0,14,"ABAD= "..abad.x..", "..abad.y, true)
|
||||
-- msg_print(0,21,"VIEW= "..vp_x..", "..vp_y, true)
|
||||
-- local hab, xx, yy = coords.world_to_tile(abad.x, abad.y)
|
||||
-- msg_print(0,28,hab.." ( "..xx..", "..yy.." )", true)
|
||||
-- msg_print(0,35,hab.." ( "..xx..", "..yy.." )", true)
|
||||
msg_print(0,42," JH= "..abad.jump_height,true)
|
||||
-- msg_print(0,42," JH= "..abad.jump_height,true)
|
||||
|
||||
-- view_coord(abad.x+8, abad.y+0, 16, 32, 6)
|
||||
-- view_coord(abad.x+abad.bb.x, abad.y+abad.bb.h, 2, 2, 4)
|
||||
-- view_coord(abad.x+abad.bb.x+abad.bb.w, abad.y+abad.bb.h, 2, 2, 2)
|
||||
-- view_coord(abad.x, abad.y, 2, 2, 3)
|
||||
|
||||
if key.press(key.T) then
|
||||
view_tile_id = not view_tile_id
|
||||
view_checking_tile = false
|
||||
end
|
||||
if key.press(key.C) then
|
||||
view_checking_tile = not view_checking_tile
|
||||
view_tile_id = false
|
||||
end
|
||||
|
||||
if view_tile_id then
|
||||
write_tile(abad.x, abad.y, 0, true, "R")
|
||||
write_tile(abad.x, abad.y+16, 0, true, "R")
|
||||
write_tile(abad.x, abad.y+32, 0, true, "R")
|
||||
|
||||
write_tile(abad.x+16, abad.y+32, 0, true, "C")
|
||||
|
||||
write_tile(abad.x+32, abad.y, 0, true, "L")
|
||||
write_tile(abad.x+32, abad.y+16, 0, true, "L")
|
||||
write_tile(abad.x+32, abad.y+32, 0, true, "L")
|
||||
end
|
||||
|
||||
if view_checking_tile then
|
||||
local msg = "FLIP= true"
|
||||
if not abad.flip then
|
||||
msg ="FLIP= false"
|
||||
view_coord(abad.x+abad.bb.w+abad.bb.x-1, abad.y+abad.bb.h-4, 2, 2, 2)
|
||||
else
|
||||
view_coord(abad.x+abad.bb.x-1, abad.y+abad.bb.h-4, 2, 2, 2)
|
||||
end
|
||||
msg_print(abad.x, abad.y-8,msg)
|
||||
end
|
||||
-- if key.press(key.T) then
|
||||
-- view_tile_id = not view_tile_id
|
||||
-- view_checking_tile = false
|
||||
-- end
|
||||
-- if key.press(key.C) then
|
||||
-- view_checking_tile = not view_checking_tile
|
||||
-- view_tile_id = false
|
||||
-- end
|
||||
--
|
||||
-- if view_tile_id then
|
||||
-- write_tile(abad.x, abad.y, 0, true, "R")
|
||||
-- write_tile(abad.x, abad.y+16, 0, true, "R")
|
||||
-- write_tile(abad.x, abad.y+32, 0, true, "R")
|
||||
--
|
||||
-- write_tile(abad.x+16, abad.y+32, 0, true, "C")
|
||||
--
|
||||
-- write_tile(abad.x+32, abad.y, 0, true, "L")
|
||||
-- write_tile(abad.x+32, abad.y+16, 0, true, "L")
|
||||
-- write_tile(abad.x+32, abad.y+32, 0, true, "L")
|
||||
-- end
|
||||
--
|
||||
-- if view_checking_tile then
|
||||
-- local msg = "FLIP= true"
|
||||
-- if not abad.flip then
|
||||
-- msg ="FLIP= false"
|
||||
-- view_coord(abad.x+abad.bb.w+abad.bb.x-1, abad.y+abad.bb.h-4, 2, 2, 2)
|
||||
-- else
|
||||
-- view_coord(abad.x+abad.bb.x-1, abad.y+abad.bb.h-4, 2, 2, 2)
|
||||
-- end
|
||||
-- msg_print(abad.x, abad.y-8,msg)
|
||||
-- end
|
||||
end
|
||||
|
||||
function msg_print(x, y, msg, direct_print )
|
||||
local scr_x, scr_y
|
||||
direct_print = direct_print or false
|
||||
if direct_print then
|
||||
scr_x = x
|
||||
scr_y = y
|
||||
else
|
||||
scr_x, scr_y = viewp:screen_coords(x, y)
|
||||
end
|
||||
draw.rectf(scr_x,scr_y,45,7,16)
|
||||
draw.text(msg,scr_x+1,scr_y+1,2)
|
||||
function collision(a, b)
|
||||
return (a.x+a.bb.x+a.bb.w >= b.x+b.bb.x)
|
||||
and (a.x+a.bb.x <= b.x+b.bb.x+b.bb.w)
|
||||
and (a.y+a.bb.y+a.bb.h >= b.y+b.bb.y)
|
||||
and (a.y+a.bb.y <= b.y+b.bb.y+b.bb.h)
|
||||
end
|
||||
|
||||
function view_coord(x, y, w, h, color)
|
||||
local scr_x, scr_y = viewp:screen_coords(x, y)
|
||||
draw.rect(scr_x, scr_y, w, h, color)
|
||||
end
|
||||
|
||||
function write_tile(x, y, yplus, print_type, align )
|
||||
local scr_x, scr_y = viewp:screen_coords(x, y)
|
||||
local hab, xx, yy = coords.world_to_tile(x, y)
|
||||
|
||||
yplus = yplus or 0
|
||||
print_type = print_type or false
|
||||
align = align or "R"
|
||||
|
||||
local txt_offset = -7
|
||||
if align=="R" then txt_offset = -14
|
||||
elseif align=="L" then txt_offset = 0
|
||||
end
|
||||
|
||||
draw.rectf(scr_x+txt_offset,scr_y+yplus,14,7,16)
|
||||
-- local msg = mapa_get_tile(hab,xx,yy)
|
||||
local msg = arc_get_tile(x,y)
|
||||
if print_type then
|
||||
msg = msg.." "..arc_check_tile(x, y)
|
||||
end
|
||||
draw.text(msg,scr_x+txt_offset+1,scr_y+1+yplus,2)
|
||||
end
|
||||
@@ -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
|
||||
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
|
||||
|
||||
function gorro.update()
|
||||
|
||||
@@ -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
|
||||
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
|
||||
|
||||
function gota:update_normal()
|
||||
|
||||
@@ -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
|
||||
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
|
||||
|
||||
function gps.update()
|
||||
|
||||
@@ -1,17 +1,21 @@
|
||||
debug = require "debug"
|
||||
arcade_config = require("arcade_config")
|
||||
coords = require "coords"
|
||||
|
||||
require "fps"
|
||||
require "fade"
|
||||
require "audio"
|
||||
require "mapa"
|
||||
require "map"
|
||||
require "mapa"
|
||||
require "logo"
|
||||
require "intro"
|
||||
require "game"
|
||||
require "switches"
|
||||
-- require "scenes"
|
||||
|
||||
|
||||
|
||||
|
||||
coords.set_config({
|
||||
tiles_width = arcade_config.tiles_width,
|
||||
tiles_height = arcade_config.tiles_height,
|
||||
@@ -178,3 +182,64 @@ function arc_textB(str, x, y, col, colB)
|
||||
draw.surf(0,0,sw,sh,x,y,dw,dh)
|
||||
surf.source(curr_surf_src)
|
||||
end
|
||||
|
||||
-- DEBUG
|
||||
|
||||
-- Imprime cualquier valor, incluyendo tablas anidadas
|
||||
function dump(value, indent)
|
||||
indent = indent or ""
|
||||
if type(value) ~= "table" then
|
||||
return tostring(value)
|
||||
end
|
||||
|
||||
local parts = {"{"}
|
||||
for k, v in pairs(value) do
|
||||
local key = (type(k) == "string") and k or "["..tostring(k).."]"
|
||||
table.insert(parts,
|
||||
string.format("%s %s = %s,",
|
||||
indent, key, dump(v, indent.." ")))
|
||||
end
|
||||
table.insert(parts, indent.."}")
|
||||
return table.concat(parts, "\n")
|
||||
end
|
||||
|
||||
function msg_print(x, y, msg, direct_print )
|
||||
local scr_x, scr_y
|
||||
direct_print = direct_print or false
|
||||
if direct_print then
|
||||
scr_x = x
|
||||
scr_y = y
|
||||
else
|
||||
scr_x, scr_y = viewp:screen_coords(x, y)
|
||||
end
|
||||
draw.rectf(scr_x,scr_y,45,7,16)
|
||||
draw.text(msg,scr_x+1,scr_y+1,2)
|
||||
end
|
||||
|
||||
function view_coord(x, y, w, h, color)
|
||||
local scr_x, scr_y = viewp:screen_coords(x, y)
|
||||
draw.rect(scr_x, scr_y, w, h, color)
|
||||
end
|
||||
|
||||
function debug.write_tile(x, y, yplus, print_type, align )
|
||||
local scr_x, scr_y = viewp:screen_coords(x, y)
|
||||
local hab, xx, yy = coords.world_to_tile(x, y)
|
||||
|
||||
yplus = yplus or 0
|
||||
print_type = print_type or false
|
||||
align = align or "R"
|
||||
|
||||
local txt_offset = -7
|
||||
if align=="R" then txt_offset = -14
|
||||
elseif align=="L" then txt_offset = 0
|
||||
end
|
||||
|
||||
draw.rectf(scr_x+txt_offset,scr_y+yplus,14,7,16)
|
||||
-- local msg = mapa_get_tile(hab,xx,yy)
|
||||
local msg = arc_get_tile(x,y)
|
||||
if print_type then
|
||||
msg = msg.." "..arc_check_tile(x, y)
|
||||
end
|
||||
draw.text(msg,scr_x+txt_offset+1,scr_y+1+yplus,2)
|
||||
end
|
||||
|
||||
|
||||
@@ -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
|
||||
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
|
||||
|
||||
function peu.update()
|
||||
|
||||
@@ -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
|
||||
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
|
||||
|
||||
function premiere.hit()
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user