I'm trying to make a hexagon grid-based game. I've got some of the fundamentals down (implemented getting neighbors of a hexagon since the library didn't natively have it and also made it so I can recolor each individual hexagon), but I can't seem to do one thing:
When I hover over a hexagon, the neighbors surrounding it get changed to line fill mode (picture example) (assume my mouse is over the top left hexagon), but I can't seem to figure out how to change them back to 'fill' when I've stopped hovering over it.
Here's the relevant code (handles checking if I'm hovering over a hexagon and deals with the neighbors):
function love.update()
mx, my = love.mouse.getPosition()
if hexGrid:containingHex(mx, my)~=nil then --am I hovering over a hexagon?
local q,r=hexGrid:containingHex(mx, my).q,hexGrid:containingHex(mx, my).r -- get the position on the grid for the hexagon
local neighbors=hexGrid:neighbors(q,r) -- get neighbors of hexagon I'm hovering over
for dir, neighbor in pairs(neighbors) do -- loop through neighbor table
if neighbor ~=nil and hexes.getHexagon(hexGrid:getHex(neighbor.q,neighbor.r))["fill"]=="fill" then -- does neighbor exist and is their fill mode "fill"?
local neighborHexagon=hexGrid:getHex(neighbor.q,neighbor.r) -- get the hexagon from the grid
local neighborData=hexes.getHexagon(neighborHexagon) -- get it's data from a seperate dictionary (stores color data and fill mode data)
neighborData["fill"]="line" -- set fill mode to line
end
end
end
end