tiles_layer2={ surf = nil, tiles = {}, } function tiles_layer2.new(_hab, _x, _y, _tx, _ty, _tw, _th) local world_x, world_y = coords.room_to_world(_hab,_x,_y) print(world_x.." "..world_y) table.insert( tiles_layer2.tiles, { hab = _hab, x = world_x, y = world_y, w = _tw, h = _th, tx = _tx, ty = _ty, tw = _tw, th = _th, } ) end function tiles_layer2.draw() for i, tile in ipairs(tiles_layer2.tiles) do if viewp:inside(tile.x, tile.y, tile.w, tile.h) then local curr_surf = surf.source() if tiles_layer2.surf ~= nil then surf.source(tiles_layer2.surf) end local scr_x, scr_y = viewp:screen_coords( tile.x, tile.y ) draw.surf(tile.tx, tile.ty, tile.tw, tile.th, scr_x, scr_y, tile.tw, tile.th) surf.source(curr_surf) end end end function tiles_layer2.update() end