46 lines
640 B
Lua
46 lines
640 B
Lua
|
function createHex()
|
||
|
local hex = {}
|
||
|
hex.centerX = 300
|
||
|
hex.centerY = 300
|
||
|
hex.size = 45
|
||
|
|
||
|
local lastX = nil
|
||
|
local lastY = nil
|
||
|
|
||
|
hex.sides = {}
|
||
|
|
||
|
for i=0,6 do
|
||
|
local angle = 2 * math.pi/6 * (i + 0.5)
|
||
|
local x = hex.centerX + hex.size * math.cos(angle)
|
||
|
local y = hex.centerY + hex.size * math.sin(angle)
|
||
|
|
||
|
if i > 0 then
|
||
|
hex.sides[i] = {lastX, lastY, x, y}
|
||
|
end
|
||
|
|
||
|
lastX = x
|
||
|
lastY = y
|
||
|
|
||
|
end
|
||
|
|
||
|
return hex
|
||
|
end
|
||
|
|
||
|
function love.load()
|
||
|
|
||
|
end
|
||
|
|
||
|
function love.update()
|
||
|
|
||
|
end
|
||
|
|
||
|
function love.draw()
|
||
|
love.graphics.setColor({255,255,255,255})
|
||
|
hex1=createHex()
|
||
|
|
||
|
for i=1, #hex1.sides do
|
||
|
love.graphics.line(unpack(hex1.sides[i]))
|
||
|
end
|
||
|
|
||
|
end
|