working on color

This commit is contained in:
Jonathan 2024-03-19 12:22:05 -05:00
parent 01a5e768ca
commit dab56a3f8c
2 changed files with 21 additions and 8 deletions

View File

@ -38,7 +38,7 @@ app:match("/map/render", function(self)
self.tiles[h][i] = map:find({x = h, y = i}) self.tiles[h][i] = map:find({x = h, y = i})
-- The map database has floor_stone and wall_floor instead of simple ASCII characters -- The map database has floor_stone and wall_floor instead of simple ASCII characters
-- So we run mapFunc:mapDecrypt to convert it back to the desired characters for visual display -- So we run mapFunc:mapDecrypt to convert it back to the desired characters for visual display
self.tiles[h][i].occupied_by_type = mapFunc:mapDecrypt(self.tiles[h][i].occupied_by_type) self.tiles[h][i].occupied_by_type = mapFunc:mapDecrypt(self.tiles[h][i].occupied_by_type)[1]
end end
end end
return {render = "map", layout = false} return {render = "map", layout = false}

View File

@ -19,11 +19,26 @@ local map = {
end end
end, end,
mapDecrypt = function(self, tile) mapDecrypt = function(self, tile)
if tile == "floor_stone" then -- TODO: Rework function so it returns both char and mat type
return "-" -- This introduces breaking changes
elseif tile == "wall_stone" then local tileset = {}
return "w" if string.find(tile, "wall") then
tileset[1] = "w"
elseif string.find(tile, "floor") then
tileset[1] = "-"
end end
if string.find(tile, "stone") then
tileset[2] = "stone"
elseif string.find(tile, "wood") then
tileset[2] = "wood"
end
return tileset
-- if tile == "floor_stone" then
-- return "-"
-- elseif tile == "wall_stone" then
-- return "w"
-- end
end, end,
-- Map Populate / check if map exists -- Map Populate / check if map exists
populate = function(self, map) populate = function(self, map)
@ -46,8 +61,6 @@ local map = {
return true return true
end end
end, end,
tileColor = function(self)
end
} }
local tiles = {} local tiles = {}