2023-04-28 17:35:52 +00:00
|
|
|
--Manage the pathfinding nodes used by DEFCON.
|
|
|
|
--This is important for a mapping tool because the DEFCON client will not load a map unless
|
|
|
|
--the pathfinding nodes form a connected graph.
|
2023-07-28 05:17:00 +00:00
|
|
|
local t = {}
|
|
|
|
local bmp = require 'bmp'
|
2023-07-28 23:23:08 +00:00
|
|
|
local lg = assert( love.graphics )
|
2023-04-28 17:35:52 +00:00
|
|
|
|
2023-07-28 05:17:00 +00:00
|
|
|
function t.load( filename )
|
|
|
|
|
2023-08-26 21:05:48 +00:00
|
|
|
local img, imgd = bmp.load( filename )
|
|
|
|
local nodes = { visible = true, points = {}, connections = {}, img = img }
|
|
|
|
|
|
|
|
print( "=== Loading Nodes: ===" )
|
|
|
|
for x = 0, 799 do
|
|
|
|
for y = 0, 399 do
|
|
|
|
if imgd:getPixel( x, 399 - y ) > 0 then
|
|
|
|
local long = 360 * ( x - 800 ) / 800 - 360 / 2 + 360
|
|
|
|
local lat = 360 * ( 600 / 800 ) * ( 600 - y ) / 600 - 180
|
|
|
|
local n = #nodes.points
|
|
|
|
nodes.points[n + 1] = long
|
|
|
|
nodes.points[n + 2] = lat
|
|
|
|
print( long, lat )
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
print( "=== Nodes Loaded ===" )
|
2023-07-28 05:17:00 +00:00
|
|
|
return setmetatable( nodes, {__index = t } )
|
|
|
|
end
|
2023-04-28 17:35:52 +00:00
|
|
|
|
2023-07-28 05:17:00 +00:00
|
|
|
function t.isConnected( nodes )
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
function t.draw( nodes )
|
2023-08-26 21:05:48 +00:00
|
|
|
lg.setPointSize( 10 )
|
|
|
|
lg.setColor( 1, 1, 1, 0.5 )
|
2023-07-28 23:23:08 +00:00
|
|
|
lg.points( nodes.points )
|
2023-07-28 05:17:00 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function t.drawConnections( nodes )
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
function t.save( nodes, filename )
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
return t
|