Improve tilesets and pass them into map renderer instead of modified map rows. #17

Merged
Jonathan merged 1 commits from Noah/Peradventure:master into master 2024-03-19 12:39:34 -05:00
3 changed files with 67 additions and 83 deletions
Showing only changes of commit 5fd5394c8e - Show all commits

View File

@ -35,14 +35,13 @@ app:match("/map/render", function(self)
for h = 1, 10 do
self.tiles[h] = {}
for i = 1, 10 do
self.tiles[h][i] = map:find({x = h, y = i})
-- 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
self.tiles[h][i].occupied_by_type = mapFunc:mapDecrypt(self.tiles[h][i].occupied_by_type)[1]
local tile = map:find({ x = h, y = i })
self.tiles[h][i] = mapFunc:mapDecrypt(tile.occupied_by_type)
end
end
return { render = "map", layout = false }
end)
return app

View File

@ -23,14 +23,14 @@ local map = {
-- This introduces breaking changes
local tileset = {}
if string.find(tile, "wall") then
tileset[1] = "w"
tileset.char = "w"
elseif string.find(tile, "floor") then
tileset[1] = "-"
tileset.char = "-"
end
if string.find(tile, "stone") then
tileset[2] = "stone"
tileset.material = "stone"
elseif string.find(tile, "wood") then
tileset[2] = "wood"
tileset.material = "wood"
end
return tileset
@ -62,20 +62,5 @@ local map = {
end
end,
}
local tiles = {}
return map

View File

@ -2,7 +2,7 @@
<% for h=1,10 do %>
<div class="grid">
<% for i=1,10 do %>
<div><%= tiles[h][i].occupied_by_type %></div>
<div><%= tiles[h][i].char %></div>
<% end %>
<br>
</div>