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 )
|
|
|
|
|
|
|
|
local colours = {
|
|
|
|
africa = {1,0,0,0.5},
|
|
|
|
europe = {0,1,0,0.5},
|
|
|
|
northamerica = {0,0,1,0.5},
|
|
|
|
russia = {0,1,1,0.5},
|
|
|
|
southamerica = {1,0,1,0.5},
|
|
|
|
southasia = {1,1,0,0.5},
|
|
|
|
sailable = {1, 1, 1, 0.2},
|
|
|
|
}
|
2023-07-28 05:17:00 +00:00
|
|
|
|
|
|
|
function t.load( filename, name )
|
2023-07-28 23:23:08 +00:00
|
|
|
local territory = {
|
|
|
|
visible = true,
|
|
|
|
name = name,
|
|
|
|
colour = colours[name],
|
|
|
|
img = assert( bmp.load( filename ) )
|
|
|
|
}
|
2023-07-28 05:17:00 +00:00
|
|
|
return setmetatable( territory, {__index = t } )
|
|
|
|
end
|
|
|
|
|
|
|
|
--World space coordinate.
|
|
|
|
function t.isValid( x, y )
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
function t.getPixel( territory, x, y )
|
|
|
|
--ZERO INDEXED
|
|
|
|
return territory.img[math.floor( 512 * ( x + 180 ) / 360 ) ][ math.floor( 285 * ( y + 100 ) / 200 ) ]
|
|
|
|
end
|
|
|
|
|
2023-07-28 23:23:08 +00:00
|
|
|
function t.toggleVisibility( territory )
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2023-07-28 05:17:00 +00:00
|
|
|
--[[
|
|
|
|
0
|
|
|
|
20 -- once sailable.bmp is brighter than this, the area is traversable by ships
|
|
|
|
60 -- once sailable.bmp and territory.bmp are brighter than this, ships can be placed here
|
|
|
|
130 -- if territory.bmp is brighter than this and sailable is darker than 60, structures are placeable.
|
|
|
|
|
|
|
|
SO:
|
|
|
|
SAILABLE: 0 (not), 21 (traverse not place), 61 ( traverse and place )
|
|
|
|
TERRITORY: 131 ( place land if sailable <= 60 ), 61 ( place sea ), 0
|
|
|
|
]]
|
|
|
|
|
2023-07-28 23:23:08 +00:00
|
|
|
function t.draw( territory )
|
|
|
|
lg.setColor( territory.colour )
|
|
|
|
lg.draw( territory.img )
|
2023-07-28 05:17:00 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function t.drawConnections( nodes )
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
function t.save( nodes, filename )
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
return t
|