extra display options, better controls, better map
This commit is contained in:
33
src/main.lua
33
src/main.lua
@@ -90,13 +90,20 @@ function love.draw()
|
||||
end
|
||||
|
||||
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)
|
||||
end
|
||||
end
|
||||
|
||||
-- draw nodes and label them
|
||||
love.graphics.setColor(1, 1, 1, 1)
|
||||
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
|
||||
love.graphics.circle("fill", node[1], node[3], node_radius / scale)
|
||||
end
|
||||
@@ -106,7 +113,7 @@ function love.draw()
|
||||
name = node[4]
|
||||
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]
|
||||
if difference > 0 then
|
||||
@@ -115,29 +122,29 @@ function love.draw()
|
||||
|
||||
local difference = node[3] + font:getHeight() - maximums[2]
|
||||
if difference > 0 then
|
||||
text_y = node[3] - (node_radius + difference) / scale
|
||||
text_z = node[3] - (node_radius + difference) / scale
|
||||
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
|
||||
|
||||
-- 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
|
||||
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
end
|
||||
if love.keyboard.isDown("=") then
|
||||
@@ -159,5 +166,7 @@ end
|
||||
function love.keypressed(key)
|
||||
if key == "escape" then
|
||||
love.event.quit()
|
||||
elseif key == "r" then
|
||||
load_map("map.json")
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user