map idea
This commit is contained in:
parent
6d41894036
commit
ad405ed590
5 changed files with 397 additions and 12 deletions
30
game_ui.lua
30
game_ui.lua
|
|
@ -51,38 +51,50 @@ function GameUI.drawVennOverlay()
|
|||
love.graphics.draw(uiVennCanvas, left, cellSize * 1.1, 0, scale, scale)
|
||||
end
|
||||
|
||||
function GameUI.drawColorVenn(room)
|
||||
if not room or not gameUiBox then return end
|
||||
-- Render the venn from explicit colour sets: `has` are the channels the player
|
||||
-- possesses (drawn as a circle), `active` the subset shown filled (the rest
|
||||
-- dotted). Restores whatever canvas was bound, so callers drawing straight to
|
||||
-- the screen (e.g. the map overlay) work as well as the in-game HUD pass.
|
||||
function GameUI.drawColorVennChannels(has, active)
|
||||
if not gameUiBox then return end
|
||||
GameUI.drawBacking()
|
||||
|
||||
local cellSize = width / gridWidth
|
||||
local sidebarWidth = cellSize * 2
|
||||
if gameUiBox.w < sidebarWidth or not uiVennCanvas then return end
|
||||
|
||||
local previousCanvas = love.graphics.getCanvas()
|
||||
love.graphics.setCanvas(uiVennCanvas)
|
||||
love.graphics.clear(0, 0, 0, 0)
|
||||
love.graphics.setBlendMode("screen")
|
||||
local radius = 9
|
||||
local dotRadius = 1
|
||||
local active = {}
|
||||
for _, color in ipairs(room:getActiveColors()) do active[color] = true end
|
||||
|
||||
for _, color in ipairs({"red", "green", "blue"}) do
|
||||
if room.player[color] then
|
||||
if has[color] then
|
||||
local layout = vennLayout[color]
|
||||
local x, y = layout.x, layout.y
|
||||
local rgb = channelColor[color]
|
||||
if active[color] then
|
||||
love.graphics.setColor(rgb[1], rgb[2], rgb[3], 1)
|
||||
love.graphics.circle("fill", x, y, radius)
|
||||
love.graphics.circle("fill", layout.x, layout.y, radius)
|
||||
else
|
||||
drawDottedCircle(x, y, radius, rgb, dotRadius)
|
||||
drawDottedCircle(layout.x, layout.y, radius, rgb, dotRadius)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
love.graphics.setCanvas(gameCanvas)
|
||||
love.graphics.setCanvas(previousCanvas)
|
||||
GameUI.drawVennOverlay()
|
||||
end
|
||||
|
||||
function GameUI.drawColorVenn(room)
|
||||
if not room or not gameUiBox then return end
|
||||
local has, active = {}, {}
|
||||
for _, color in ipairs({"red", "green", "blue"}) do
|
||||
if room.player[color] then has[color] = true end
|
||||
end
|
||||
for _, color in ipairs(room:getActiveColors()) do active[color] = true end
|
||||
GameUI.drawColorVennChannels(has, active)
|
||||
end
|
||||
|
||||
return GameUI
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue