extra display options, better controls, better map
This commit is contained in:
@@ -10,10 +10,17 @@ to completely hide a node. `edges` is an array of arrays of two names of nodes.
|
|||||||
An optional 3rd item can be set to `false` to hide an edge, or a string for a
|
An optional 3rd item can be set to `false` to hide an edge, or a string for a
|
||||||
custom label. `edges` can be nonexistent.
|
custom label. `edges` can be nonexistent.
|
||||||
|
|
||||||
WASD panning and -/+ to zoom.
|
Pan with WASD or arrow keys.
|
||||||
|
Zoom with +/- keys.
|
||||||
|
`r` to reload the default map.
|
||||||
|
|
||||||
You can drag and drop a JSON file to load it.
|
You can drag and drop a JSON file to load it.
|
||||||
|
|
||||||
|
Both nodes and edges can have an extra object with metadata, some of which is
|
||||||
|
used by this program. An array called `offset` will adjust the positioning of
|
||||||
|
labels. An array called `color` will set the color via 0 to 1 RGBA values
|
||||||
|
(node only).
|
||||||
|
|
||||||
## Example JSON
|
## Example JSON
|
||||||
|
|
||||||
```json
|
```json
|
||||||
|
|||||||
61
map.json
61
map.json
@@ -1,55 +1,68 @@
|
|||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"Second Farm": [-260, 67, -263, true],
|
"Second Farm": [-260, 67, -263, true, {"offset": [-40, 0], "color": [0, 1, 0, 1]}],
|
||||||
"tree farm north": [-164, 71, -267, false],
|
"tree farm north": [-164, 71, -267, false],
|
||||||
"Tree Farm": [-156, 68, -252, true],
|
"Tree Farm": [-156, 68, -252, true, {"color": [0, 0.75, 0, 1]}],
|
||||||
"farm paths diverge point": [-157, 71, -15, false],
|
"farm paths diverge point": [-157, 71, -15, false],
|
||||||
"First Farm": [-146, 74, 10, true],
|
"First Farm": [-146, 74, 10, true, {"color": [0, 1, 0, 1]}],
|
||||||
"1st water crossing / halfway point": [-51, 64, 24, false],
|
"1st water crossing / halfway point": [-51, 64, 24, false],
|
||||||
"1st path split": [0, 95, 36, false],
|
"1st path split": [0, 95, 36, false],
|
||||||
"Spawn Point": [0, 87, 0, "Spawn"],
|
"Spawn Point": [0, 87, 0, "Spawn", {"offset": [-46, -20]}],
|
||||||
"Warehouse/Mine": [84, 110, 76, true],
|
"Warehouse/Mine": [84, 110, 76, true, {"offset": [2, -10]}],
|
||||||
"to village curve point": [139, 105, 145, false],
|
"to village curve point": [139, 105, 145, false],
|
||||||
"Cliffspawn Village Bridge": [130, 104, 255, false],
|
"Cliffspawn Village Bridge": [130, 104, 255, false],
|
||||||
"Cliffspawn Village": [147, 96, 305, true],
|
"Cliffspawn Village": [147, 96, 305, true, {"color": [0.67, 0.5, 0.33, 1]}],
|
||||||
"spawn hovel": [4, 91, -10, false],
|
"spawn hovel": [4, 91, -10, false],
|
||||||
"zombie spawner (hovel mine)": [96, 32, 26, "Zombie Dungeon"],
|
"zombie spawner (hovel mine)": [96, 32, 26, "Zombie Dungeon", {"color": [0, 0.5, 0, 1]}],
|
||||||
"geode (hovel mine)": [126, -37, -12, "geode"],
|
"geode (hovel mine)": [126, -37, -12, "geode", {"color": [0.5, 0.25, 1, 1]}],
|
||||||
"future sand mine": [191, 63, -297, true],
|
"future sand mine": [191, 63, -297, true, {"color": [1, 1, 0, 1]}],
|
||||||
"skeleton spawner (1st mine)": [119, 36, 92, true, "Skelton Dungeon"],
|
"skeleton spawner (1st mine)": [119, 36, 92, "Skeleton Dungeon"],
|
||||||
"Mount Sharpe": [696, 178, 667, true],
|
"Mount Sharpe": [696, 178, 667, true],
|
||||||
"Great Rock Waterfall": [814, 120, 601, true],
|
"Great Rock Waterfall": [814, 120, 601, true, {"color": [0.38, 0.38, 1, 1]}],
|
||||||
"Great Rock Waterfall (bottom)": [809, 74, 536, false],
|
"Great Rock Waterfall (bottom)": [809, 74, 536, false],
|
||||||
"waterfall 2 top": [832, 121, 631, false],
|
"waterfall 2 top": [832, 121, 631, "", {"color": [0.38, 0.38, 1, 1], "offset": [0, 2]}],
|
||||||
"waterfall 2 bottom": [884, 82, 628, false],
|
"waterfall 2 bottom": [884, 82, 628, false],
|
||||||
"Ruined Nether Portal": [853, 79, 805, true],
|
"Ruined Nether Portal": [853, 79, 805, true, {"color": [1, 0.25, 0, 1]}],
|
||||||
"Trickster Waterfall": [439, 81, 743, true],
|
"Trickster Waterfall": [439, 81, 743, true, {"color": [0.38, 0.38, 1, 1]}],
|
||||||
"Trickster Waterfall (bottom)": [441, 62, 730, false],
|
"Trickster Waterfall (bottom)": [441, 62, 730, false],
|
||||||
"village crossroad": [130, 101, 296, false, {"notes": "insignificant"}],
|
"village crossroad": [130, 101, 296, false, {"notes": "insignificant"}],
|
||||||
"Second Farm original route corner": [-180, 69, -30, false],
|
"Second Farm original route corner": [-180, 69, -30, false],
|
||||||
"Second Farm original route corner 2": [-202, 79, -169, false]
|
"Second Farm original route corner 2": [-202, 79, -169, false],
|
||||||
|
"cherry blossum divergence point": [-332, 104, -423],
|
||||||
|
"original farm worldborder deadend": [-346, 109, -456],
|
||||||
|
"Cherry Point": [-480, 104, -404, true, {"color": [1, 0.67, 0.67, 1]}],
|
||||||
|
"unnamed beach point": [-376, 63, -313],
|
||||||
|
"unnamed summit curve point": [-387, 119, -229],
|
||||||
|
"unnamed summit": [-408, 130, -251],
|
||||||
|
"Sugarcane Point": [-161, 62, -365, true, {"color": [0.75, 1, 0.25, 1]}]
|
||||||
},
|
},
|
||||||
"edges": [
|
"edges": [
|
||||||
["tree farm north", "Second Farm"],
|
["tree farm north", "Second Farm", null, {"offset": [0, -12]}],
|
||||||
["tree farm north", "farm paths diverge point"],
|
["tree farm north", "farm paths diverge point"],
|
||||||
["farm paths diverge point", "First Farm"],
|
["farm paths diverge point", "First Farm", null, {"offset": [0, -8]}],
|
||||||
["First Farm", "1st water crossing / halfway point"],
|
["First Farm", "1st water crossing / halfway point", null, {"offset": [0, -12]}],
|
||||||
["1st water crossing / halfway point", "1st path split"],
|
["1st water crossing / halfway point", "1st path split", null, {"offset": [-4, 6]}],
|
||||||
["1st path split", "Spawn Point"],
|
["1st path split", "Spawn Point"],
|
||||||
["Spawn Point", "Warehouse/Mine"],
|
["Spawn Point", "Warehouse/Mine"],
|
||||||
["Warehouse/Mine", "to village curve point"],
|
["Warehouse/Mine", "to village curve point", null, {"offset": [-14, 6]}],
|
||||||
["to village curve point", "Cliffspawn Village Bridge"],
|
["to village curve point", "Cliffspawn Village Bridge"],
|
||||||
["Second Farm", "farm paths diverge point"],
|
["Second Farm", "farm paths diverge point", false, {"notes": "replaced with more detailed representation"}],
|
||||||
["1st path split", "Warehouse/Mine", false, {"notes": "not real"}],
|
["1st path split", "Warehouse/Mine", false, {"notes": "not real"}],
|
||||||
["Cliffspawn Village", "Cliffspawn Village Bridge"],
|
["Cliffspawn Village", "Cliffspawn Village Bridge"],
|
||||||
["spawn hovel", "geode (hovel mine)"],
|
["spawn hovel", "geode (hovel mine)"],
|
||||||
["spawn hovel", "zombie spawner (hovel mine)"],
|
["spawn hovel", "zombie spawner (hovel mine)"],
|
||||||
["Warehouse/Mine", "skeleton spawner (1st mine)", false],
|
["Warehouse/Mine", "skeleton spawner (1st mine)", ""],
|
||||||
["Great Rock Waterfall", "Great Rock Waterfall (bottom)"],
|
["Great Rock Waterfall", "Great Rock Waterfall (bottom)"],
|
||||||
["waterfall 2 top", "waterfall 2 bottom"],
|
["waterfall 2 top", "waterfall 2 bottom"],
|
||||||
["Trickster Waterfall", "Trickster Waterfall (bottom)", ""],
|
["Trickster Waterfall", "Trickster Waterfall (bottom)", ""],
|
||||||
["farm paths diverge point", "Second Farm original route corner"],
|
["farm paths diverge point", "Second Farm original route corner", null, {"offset": [-32, 6]}],
|
||||||
["Second Farm original route corner", "Second Farm original route corner 2"],
|
["Second Farm original route corner", "Second Farm original route corner 2"],
|
||||||
["Second Farm original route corner 2", "Second Farm"]
|
["Second Farm original route corner 2", "Second Farm"],
|
||||||
|
["Second Farm", "cherry blossum divergence point"],
|
||||||
|
["original farm worldborder deadend", "cherry blossum divergence point"],
|
||||||
|
["Cherry Point", "cherry blossum divergence point"],
|
||||||
|
["unnamed summit curve point", "unnamed beach point"],
|
||||||
|
["unnamed summit curve point", "unnamed summit", null, {"offset": [-14, 10]}],
|
||||||
|
["Sugarcane Point", "Second Farm"]
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
33
src/main.lua
33
src/main.lua
@@ -90,13 +90,20 @@ function love.draw()
|
|||||||
end
|
end
|
||||||
|
|
||||||
love.graphics.setColor(0.67, 0.67, 0.67, 1)
|
love.graphics.setColor(0.67, 0.67, 0.67, 1)
|
||||||
|
if edge[4] and edge[4].offset then
|
||||||
|
-- these actually work better not scale-adjusted
|
||||||
|
center_x = center_x + edge[4].offset[1]
|
||||||
|
center_z = center_z + edge[4].offset[2]
|
||||||
|
end
|
||||||
love.graphics.print(distance, center_x, center_z - font:getHeight() / 2, 0, 1 / scale, 1 / scale)
|
love.graphics.print(distance, center_x, center_z - font:getHeight() / 2, 0, 1 / scale, 1 / scale)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- draw nodes and label them
|
-- draw nodes and label them
|
||||||
love.graphics.setColor(1, 1, 1, 1)
|
|
||||||
for name, node in pairs(nodes) do
|
for name, node in pairs(nodes) do
|
||||||
|
local color = node[5] and node[5].color or {1, 1, 1, 1}
|
||||||
|
love.graphics.setColor(color)
|
||||||
|
|
||||||
if not (node[4] == false) then
|
if not (node[4] == false) then
|
||||||
love.graphics.circle("fill", node[1], node[3], node_radius / scale)
|
love.graphics.circle("fill", node[1], node[3], node_radius / scale)
|
||||||
end
|
end
|
||||||
@@ -106,7 +113,7 @@ function love.draw()
|
|||||||
name = node[4]
|
name = node[4]
|
||||||
end
|
end
|
||||||
|
|
||||||
local text_x, text_y = node[1] + node_radius / scale, node[3] + node_radius / scale
|
local text_x, text_z = node[1] + node_radius / scale, node[3] + node_radius / scale
|
||||||
|
|
||||||
local difference = node[1] + font:getWidth(name) - maximums[1]
|
local difference = node[1] + font:getWidth(name) - maximums[1]
|
||||||
if difference > 0 then
|
if difference > 0 then
|
||||||
@@ -115,29 +122,29 @@ function love.draw()
|
|||||||
|
|
||||||
local difference = node[3] + font:getHeight() - maximums[2]
|
local difference = node[3] + font:getHeight() - maximums[2]
|
||||||
if difference > 0 then
|
if difference > 0 then
|
||||||
text_y = node[3] - (node_radius + difference) / scale
|
text_z = node[3] - (node_radius + difference) / scale
|
||||||
end
|
end
|
||||||
|
|
||||||
love.graphics.print(name, text_x, text_y, 0, 1 / scale, 1 / scale)
|
if node[5] and node[5].offset then
|
||||||
|
text_x = text_x + node[5].offset[1] / scale
|
||||||
|
text_z = text_z + node[5].offset[2] / scale
|
||||||
|
end
|
||||||
|
love.graphics.print(name, text_x, text_z, 0, 1 / scale, 1 / scale)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- TEMP center of map
|
|
||||||
-- love.graphics.setColor(1, 1, 1, 1)
|
|
||||||
-- love.graphics.circle("fill", minimums[1] + (maximums[1] - minimums[1]) / 2, minimums[2] + (maximums[2] - minimums[2]) / 2, node_radius / scale)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.update(dt)
|
function love.update(dt)
|
||||||
if love.keyboard.isDown("w") then
|
if love.keyboard.isDown("w") or love.keyboard.isDown("up") then
|
||||||
translation[2] = translation[2] + translation_adjust_speed / scale * dt
|
translation[2] = translation[2] + translation_adjust_speed / scale * dt
|
||||||
end
|
end
|
||||||
if love.keyboard.isDown("s") then
|
if love.keyboard.isDown("s") or love.keyboard.isDown("down") then
|
||||||
translation[2] = translation[2] - translation_adjust_speed / scale * dt
|
translation[2] = translation[2] - translation_adjust_speed / scale * dt
|
||||||
end
|
end
|
||||||
if love.keyboard.isDown("a") then
|
if love.keyboard.isDown("a") or love.keyboard.isDown("left") then
|
||||||
translation[1] = translation[1] + translation_adjust_speed / scale * dt
|
translation[1] = translation[1] + translation_adjust_speed / scale * dt
|
||||||
end
|
end
|
||||||
if love.keyboard.isDown("d") then
|
if love.keyboard.isDown("d") or love.keyboard.isDown("right") then
|
||||||
translation[1] = translation[1] - translation_adjust_speed / scale * dt
|
translation[1] = translation[1] - translation_adjust_speed / scale * dt
|
||||||
end
|
end
|
||||||
if love.keyboard.isDown("=") then
|
if love.keyboard.isDown("=") then
|
||||||
@@ -159,5 +166,7 @@ end
|
|||||||
function love.keypressed(key)
|
function love.keypressed(key)
|
||||||
if key == "escape" then
|
if key == "escape" then
|
||||||
love.event.quit()
|
love.event.quit()
|
||||||
|
elseif key == "r" then
|
||||||
|
load_map("map.json")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user