This commit is contained in:
wan-may 2023-07-28 02:42:16 -03:00
parent 8eed23c87d
commit 171177ea82
5 changed files with 41 additions and 7 deletions

View File

@ -17,7 +17,7 @@ end
function Camera.Translate( x, y ) function Camera.Translate( x, y )
x = x or 0 x = x or 0
y = y or 0 y = y or 0
return Camera.Set( Camera.x + x, Camera.y + y, Camera.w, Camera.h) return Camera.Set( math.max(-180, math.min(360, Camera.x + x)), math.min(100, Camera.y + y), Camera.w, Camera.h)
end end
--In world coordinates: top left corner at x, y, extent of w, h. --In world coordinates: top left corner at x, y, extent of w, h.

View File

@ -1,5 +1,5 @@
--Load and save the fixed width plaintext data used by DEFCON. --Load and save the fixed width plaintext data used by DEFCON.
local t = {} local t = { visible = true, active = false}
local io = io local io = io
local math = math local math = math
local table = table local table = table
@ -14,17 +14,18 @@ local caps = {}
t.selectedCity = nil t.selectedCity = nil
function t.draw() function t.draw()
lg.points( points ) if t.visible then lg.points( points ) end
end end
function t.drawSelected( r ) function t.drawSelected( r )
if not t.visible then return end
local c = t.selectedCity local c = t.selectedCity
if not c then return end if not c then return end
lg.circle( "fill", c.x, c.y, r ) lg.circle( "fill", c.x, c.y, r )
end end
function t.drawCapitals() function t.drawCapitals()
lg.points( caps ) if t.visible then lg.points( caps ) end
end end
function t.selectNearestCity(x, y) function t.selectNearestCity(x, y)

View File

@ -4,7 +4,7 @@ local lfs = love.filesystem
local lg = love.graphics local lg = love.graphics
function t.load( filename ) function t.load( filename )
local polys = {} local polys = { visible = true }
local poly = {} local poly = {}
local n = 0 local n = 0
local k = 1 local k = 1
@ -29,9 +29,22 @@ end
function t.save( lines, filename ) function t.save( lines, filename )
end
function t.newPolygon( x, y )
end
function t.addToCurrentPolygon( x, y )
end
function t.deletePolygon( )
end end
function t.draw( lines ) function t.draw( lines )
if not lines.visible then return end
for _, poly in ipairs( lines ) do for _, poly in ipairs( lines ) do
lg.line( poly ) lg.line( poly )
end end

View File

@ -48,6 +48,11 @@ function love.draw()
love.graphics.rectangle( "line", love.graphics.getWidth() / 2, h, love.graphics.getWidth() / 2, 30 ) love.graphics.rectangle( "line", love.graphics.getWidth() / 2, h, love.graphics.getWidth() / 2, 30 )
if map.cities.selectedCity then if map.cities.selectedCity then
local c = map.cities.selectedCity local c = map.cities.selectedCity
love.graphics.setColor( 0.2, 0.1, 0.1, 0.5 )
love.graphics.rectangle( "fill", 0, 0, 150 ,100 )
love.graphics.setColor( 1, 1, 1, 1 )
love.graphics.rectangle( "line", 0, 0, 150 ,100 )
love.graphics.setColor( 1.2, 1.1, 1.1, 1.5 )
love.graphics.print( ("NAME: %s\nX: %3.2f\nY: %3.2f\nPOP: %d\nCAPITAL: %s\nCOUNTRY: %s"):format(c.name, c.x, c.y, c.pop, tostring(c.capital), c.country), 0, 0 ) love.graphics.print( ("NAME: %s\nX: %3.2f\nY: %3.2f\nPOP: %d\nCAPITAL: %s\nCOUNTRY: %s"):format(c.name, c.x, c.y, c.pop, tostring(c.capital), c.country), 0, 0 )
end end
end end
@ -62,6 +67,11 @@ end
function love.mousepressed( x, y, button, istouch, presses ) function love.mousepressed( x, y, button, istouch, presses )
local wx, wy = Camera.GetWorldCoordinate( x, y ) local wx, wy = Camera.GetWorldCoordinate( x, y )
if button == 1 then
map.cities.lockSelection()
else
map.cities.unlockSelection()
end
print( ("MOUSE\tx %f\ty %f\twx %f\twy %f"):format(x, y, wx, wy) ) print( ("MOUSE\tx %f\ty %f\twx %f\twy %f"):format(x, y, wx, wy) )
end end
@ -74,5 +84,14 @@ function love.keypressed(key)
-- To open a file or folder, "file://" must be prepended to the path. -- To open a file or folder, "file://" must be prepended to the path.
love.system.openURL("file://"..love.filesystem.getSaveDirectory()) love.system.openURL("file://"..love.filesystem.getSaveDirectory())
end end
if key == "1" then
map.coastlines.visible = not map.coastlines.visible
end
if key == "2" then
map.coastlinesLow.visible = not map.coastlinesLow.visible
end
if key == "3" then
map.international.visible = not map.international.visible
end
wasKeyPressed = true wasKeyPressed = true
end end

View File

@ -39,6 +39,7 @@ function map.draw()
lg.replaceTransform( Camera.tf ) lg.replaceTransform( Camera.tf )
do --points do --points
lg.setColor( 1, 0, 0, 0.5 ) lg.setColor( 1, 0, 0, 0.5 )
lg.setPointSize( 0.5 * Camera.zoom ) lg.setPointSize( 0.5 * Camera.zoom )
map.cities.draw() map.cities.draw()
@ -79,7 +80,7 @@ function map.save()
end end
function map.setVisible() function map.hover(x, y)
end end