hexgrid: Create grid x axis implemented
This commit is contained in:
parent
31e148bf48
commit
259a96370b
@ -30,13 +30,34 @@ function createHex(centerX, centerY)
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
return hex
|
||||
end
|
||||
|
||||
function love.load()
|
||||
function createGrid()
|
||||
|
||||
hexes = {}
|
||||
|
||||
--width and height of hex grid
|
||||
maxX = 10
|
||||
maxY = 1
|
||||
|
||||
centerX = 50
|
||||
centerY = 50
|
||||
for y=1, maxY do
|
||||
for x=1, maxX do
|
||||
if x == 1 then
|
||||
hexes[x] = createHex (centerX, centerY)
|
||||
else
|
||||
centerX = hexes[x-1].centerX + hexes[x-1].width
|
||||
hexes[x] = createHex( centerX, centerY)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function love.load()
|
||||
createGrid()
|
||||
end
|
||||
|
||||
function love.update()
|
||||
@ -48,28 +69,34 @@ function love.draw()
|
||||
|
||||
--create our first hex #note: this will all end up
|
||||
--in a single for loop to draw a complete grid
|
||||
temp=createHex (300,300)
|
||||
hex1=createHex(0+temp.width,0+temp.height)
|
||||
-- temp=createHex (300,300)
|
||||
-- hex1=createHex(0+temp.width,0+temp.height)
|
||||
|
||||
for i=1, #hex1.sides do
|
||||
love.graphics.line(unpack(hex1.sides[i]))
|
||||
-- for i=1, #hex1.sides do
|
||||
-- love.graphics.line(unpack(hex1.sides[i]))
|
||||
-- end
|
||||
----------------------
|
||||
for h=1, #hexes do
|
||||
for l=1, #hexes[h].sides do
|
||||
love.graphics.line(unpack(hexes[h].sides[l]))
|
||||
end
|
||||
end
|
||||
|
||||
--Here we create another hex and place it to the side
|
||||
newCenterX = hex1.centerX + hex1.width
|
||||
hex2=createHex(newCenterX,hex1.centerY)
|
||||
-- newCenterX = hex1.centerX + hex1.width
|
||||
-- hex2=createHex(newCenterX,hex1.centerY)
|
||||
|
||||
for i=1, #hex2.sides do
|
||||
love.graphics.line(unpack(hex2.sides[i]))
|
||||
end
|
||||
-- for i=1, #hex2.sides do
|
||||
-- love.graphics.line(unpack(hex2.sides[i]))
|
||||
-- end
|
||||
|
||||
-- Here we want to move down a row and base it from the first hex
|
||||
newCenterY = hex1.centerY+(hex1.height * 3/4)
|
||||
newCenterX = (hex1.centerX + hex2.centerX)/2
|
||||
hex3 = createHex(newCenterX, newCenterY)
|
||||
-- newCenterY = hex1.centerY+(hex1.height * 3/4)
|
||||
-- newCenterX = (hex1.centerX + hex2.centerX)/2
|
||||
-- hex3 = createHex(newCenterX, newCenterY)
|
||||
|
||||
for i=1, #hex3.sides do
|
||||
love.graphics.line(unpack(hex3.sides[i]))
|
||||
end
|
||||
-- for i=1, #hex3.sides do
|
||||
-- love.graphics.line(unpack(hex3.sides[i]))
|
||||
-- end
|
||||
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user