Compare commits

...

3 Commits

13 changed files with 201 additions and 176 deletions

View File

@@ -29,27 +29,10 @@ abad={}
function abad_nop() function abad_nop()
end 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() 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,
@@ -211,8 +194,8 @@ function abad_jump()
else else
local tile1_hit = arc_get_tile(x1_check, y_check ) local tile1_hit = arc_get_tile(x1_check, y_check )
local tile2_hit = arc_get_tile(x2_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_block1 = mapa_is_half_block_tile(map_to_editor_tile(tile1_hit))
local half_block2 = mapa_is_half_block_tile(tile2_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_block1 = tile1_hit_type == tiletype.block and not half_block1
local full_block2 = tile2_hit_type == tiletype.block and not half_block2 local full_block2 = tile2_hit_type == tiletype.block and not half_block2
local full_block = full_block1 and full_block2 local full_block = full_block1 and full_block2
@@ -232,7 +215,8 @@ function abad_jump()
-- permetre continuar en el salt -- permetre continuar en el salt
if not full_block and half_block then if not full_block and half_block then
if abad.jump_in_half_block==0 and not abad.jump_in_half_block_used 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 end
if abad.jump_in_half_block>0 then if abad.jump_in_half_block>0 then
abad.y=abad.y-vspace abad.y=abad.y-vspace

View File

@@ -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

View File

@@ -3,9 +3,11 @@
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 }, shot={
{ 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 },
{ 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)
@@ -17,15 +19,20 @@ cacau={
-- cacau.alive = true -- cacau.alive = true
-- end -- end
function cacau.shots()
-- print(cacau[1].name)
return cacau.shot
end
function cacau.init(_x,_y,_flip,_power,_num_shots,_type_shot) function cacau.init(_x,_y,_flip,_power,_num_shots,_type_shot)
if _type_shot==type_shot.linear then if _type_shot==type_shot.linear then
for ns=1,_num_shots do for ns=1,_num_shots do
if cacau[ns].alive == true then break end if cacau.shot[ns].alive == true then break end
cacau[ns].x=_x cacau.shot[ns].x=_x
cacau[ns].y=_y cacau.shot[ns].y=_y
cacau[ns].flip=_flip cacau.shot[ns].flip=_flip
cacau[ns].alive = true cacau.shot[ns].alive = true
cacau[ns].power = _power cacau.shot[ns].power = _power
end end
elseif _type_shot==type_shot.rear then elseif _type_shot==type_shot.rear then
@@ -38,7 +45,7 @@ function cacau:available(_num_shots,_type_shot)
local avail_shots = false local avail_shots = false
if _type_shot==type_shot.linear then if _type_shot==type_shot.linear then
for ns=1,_num_shots do 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 end
elseif _type_shot==type_shot.rear then elseif _type_shot==type_shot.rear then
@@ -49,10 +56,14 @@ function cacau:available(_num_shots,_type_shot)
return avail_shots return avail_shots
end end
function cacau:kill(shot)
shot.alive = false
end
function cacau.draw() function cacau.draw()
for ns=1,3 do for ns=1,3 do
if cacau[ns].alive==true then if cacau.shot[ns].alive==true then
local cx, cy = viewp:screen_coords(cacau[ns].x, cacau[ns].y) local cx, cy = viewp:screen_coords(cacau.shot[ns].x, cacau.shot[ns].y)
draw.circf( cx, cy, 4,16) draw.circf( cx, cy, 4,16)
draw.circf( cx+4, cy, 4,16) draw.circf( cx+4, cy, 4,16)
draw.circf( cx , cy, 2,6) draw.circf( cx , cy, 2,6)
@@ -63,30 +74,30 @@ end
function cacau.update() function cacau.update()
for ns=1,3 do for ns=1,3 do
if cacau[ns].alive==true then if cacau.shot[ns].alive==true then
if viewp:inside(cacau[ns].x, cacau[ns].y, cacau[ns].w, cacau[ns].h)==false then if viewp:inside(cacau.shot[ns].x, cacau.shot[ns].y, cacau.shot[ns].w, cacau.shot[ns].h)==false then
cacau[ns].hab=-1 cacau.shot[ns].hab=-1
cacau[ns].alive=false cacau.shot[ns].alive=false
break break
end end
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 local step=3
if cacau[ns].flip then step=-step end if cacau.shot[ns].flip then step=-step end
cacau[ns].x=cacau[ns].x+step 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 if viewp:inside(cacau.shot[ns].x, cacau.shot[ns].y, cacau.shot[ns].w, cacau.shot[ns].h)==false then
cacau[ns].alive=false cacau.shot[ns].alive=false
break break
end end
else else
cacau[ns].hab=-1 cacau.shot[ns].hab=-1
cacau[ns].alive = false cacau.shot[ns].alive = false
end end
end end
end end

View File

@@ -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

View File

@@ -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

View File

@@ -1,8 +1,4 @@
arcade_config = require("arcade_config")
viewport= require("viewport") viewport= require("viewport")
require "fps"
require "mapa"
require "abad" require "abad"
require "cacau" require "cacau"
require "caco" require "caco"
@@ -189,7 +185,18 @@ function update_game()
-- end -- end
-- end -- 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
end
cacau.update() cacau.update()
switches.update() switches.update()
@@ -210,8 +217,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
@@ -220,88 +226,56 @@ function update_game()
score.draw() score.draw()
fps_print() fps_print()
viewp:print() -- viewp:print()
msg_print(0,14,"ABAD= "..abad.x..", "..abad.y, true) -- msg_print(0,14,"ABAD= "..abad.x..", "..abad.y, true)
msg_print(0,21,"VIEW= "..vp_x..", "..vp_y, true) -- msg_print(0,21,"VIEW= "..vp_x..", "..vp_y, true)
local hab, xx, yy = coords.world_to_tile(abad.x, abad.y) -- local hab, xx, yy = coords.world_to_tile(abad.x, abad.y)
msg_print(0,28,hab.." ( "..xx..", "..yy.." )", true) -- msg_print(0,28,hab.." ( "..xx..", "..yy.." )", true)
-- msg_print(0,35,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+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.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.bb.x+abad.bb.w, abad.y+abad.bb.h, 2, 2, 2)
-- view_coord(abad.x, abad.y, 2, 2, 3) -- view_coord(abad.x, abad.y, 2, 2, 3)
if key.press(key.T) then -- if key.press(key.T) then
view_tile_id = not view_tile_id -- view_tile_id = not view_tile_id
view_checking_tile = false -- view_checking_tile = false
end -- end
if key.press(key.C) then -- if key.press(key.C) then
view_checking_tile = not view_checking_tile -- view_checking_tile = not view_checking_tile
view_tile_id = false -- 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 end
if view_tile_id then function collision(a, b)
write_tile(abad.x, abad.y, 0, true, "R") return (a.x+a.bb.x+a.bb.w >= b.x+b.bb.x)
write_tile(abad.x, abad.y+16, 0, true, "R") and (a.x+a.bb.x <= b.x+b.bb.x+b.bb.w)
write_tile(abad.x, abad.y+32, 0, true, "R") 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)
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 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)
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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -1,17 +1,21 @@
debug = require "debug"
arcade_config = require("arcade_config") arcade_config = require("arcade_config")
coords = require "coords" coords = require "coords"
require "fps" require "fps"
require "fade" require "fade"
require "audio" require "audio"
require "mapa"
require "map" require "map"
require "mapa"
require "logo" require "logo"
require "intro" require "intro"
require "game" require "game"
require "switches" require "switches"
-- require "scenes" -- require "scenes"
coords.set_config({ coords.set_config({
tiles_width = arcade_config.tiles_width, tiles_width = arcade_config.tiles_width,
tiles_height = arcade_config.tiles_height, 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) draw.surf(0,0,sw,sh,x,y,dw,dh)
surf.source(curr_surf_src) surf.source(curr_surf_src)
end 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

View File

@@ -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

View File

@@ -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

View File

@@ -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