Files
paku/data/rooms.lua
Raimon Zamora bbbf9d0c50 - [CHG] Mòdul "level" renomenat a "rooms"
- [NEW] Mòdul "menu"
- [NEW] Mòdul "popup"
2025-06-19 22:11:05 +02:00

95 lines
2.4 KiB
Lua

rooms = {
surf_background = nil,
surf_foreground = nil,
surf_items = nil,
surf_original_items = nil,
pos = {x=10*8, y=0},
init = function()
rooms.pos.x, rooms.pos.y = 0,0
if rooms.surf_background ~= nil then surf.free(rooms.surf_background) end
rooms.surf_background = surf.load("rooms_background.bin")
--rooms.surf_background = surf.new(20*8,12*8)
if rooms.surf_foreground ~= nil then surf.free(rooms.surf_foreground) end
rooms.surf_foreground = surf.load("rooms_foreground.bin")
--rooms.surf_foreground = surf.new(20*8,12*8)
if rooms.surf_items ~= nil then surf.free(rooms.surf_items) end
rooms.surf_items = surf.load("rooms_items.bin")
--rooms.surf_items = surf.new(20*8,12*8)
rooms.surf_original_items = surf.new(20*8,12*8)
surf.source(rooms.surf_items)
surf.target(rooms.surf_original_items)
draw.surf(0,0,160,96,0,0)
--map.surf(rooms.surf_background)
--for y=0,12*8 do
-- for x=0,20*8 do
-- map.tile(x,y,1)
-- end
--end
--map.surf(rooms.surf_foreground)
--map.tile(10,10,16)
--surf.save(rooms.surf_background, "data/rooms_background.bin")
--surf.save(rooms.surf_foreground, "data/rooms_foreground.bin")
--surf.save(rooms.surf_items, "data/rooms_items.bin")
--shader.init("lynx.glsl")
--shader.enable();
end,
draw = function()
-- Retallem la pantalla a la zona de joc
view.clip(0,8,160,96)
-- Movem la càmara a l'habitació on estem
view.origin(rooms.pos.x*8,rooms.pos.y*8+8)
-- Pintem el background
surf.source(tiles)
map.surf(rooms.surf_background)
map.draw()
-- Movem 4x4 pixels la càmara per a pintar les sombres dels sprites i el foreground
view.origin(rooms.pos.x*8+4,rooms.pos.y*8+12)
-- Pintem el foreground de negre
map.surf(rooms.surf_foreground)
pal.subpal(0,32,1)
map.draw()
-- Pintem els sprites de negre
-- [TODO]
surf.source(sprites)
draw.surf(0, 0, 16, 17, 10, 10, 16, 17)
-- Movem la càmara al lloc que toca de nou, i tornem la paleta normal
view.origin(rooms.pos.x*8,rooms.pos.y*8+8)
pal.subpal()
-- Pintem el foreground
surf.source(tiles)
map.surf(rooms.surf_foreground)
map.draw()
-- Pintem els sprites
-- [TODO]
surf.source(sprites)
draw.surf(0, 0, 16, 17, 10, 10, 16, 17)
-- Pintem la rejilla
--for y=0,12 do draw.line(0,y*8, 160, y*8, 27) end
--for x=0,20 do draw.line(x*8, 0, x*8, 104, 27) end
end,
peiv = function()
pal.color(1, 1, 1, 1)
return "HOLA OTHER UNIT"
end
}