fixed initialization display bugs on game page

This commit is contained in:
Jonathan 2024-03-28 09:58:20 -05:00
parent e0e6c30752
commit d9610bea3b
4 changed files with 24 additions and 7 deletions

View File

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

Binary file not shown.

View File

@ -29,6 +29,10 @@ sqlite3 database.sqlite3 "
);
CREATE TABLE IF NOT EXISTS players (
id INTEGER PRIMARY KEY AUTOINCREMENT,
player_name TEXT
player_name TEXT,
x INTEGER,
y INTEGER,
health INTEGER,
game_ref INTEGER
)
"

View File

@ -2,14 +2,21 @@
<script src="/static/htmx.min.js"></script>
<% if not isPopulated then %>
<div id="clickable">
<button hx-post="/clickme" hx-target="#clickable">Start</button>
<button hx-post="/clickme" hx-target="#clickable" onclick="location.reload()">Start</button>
</div>
<% end %>
<article class="container-fluid">
<p style="text-align: center;">Game</p>
<main style="width: 50%;" class="container" id="map" hx-get="/map/render" hx-trigger="every 10s,load">
<div class="grid">
<script></script>
<% if isPopulated then %>
<div>
<p style="text-align: center;">Map</p>
<main style="width: 50%;" class="container" id="map" hx-get="/map/render" hx-trigger="every 5s,load">
</div>
</main>
<div>
<% render("views.player_ui") %>
</div>
<% end %>
</div>
</article>