Code: Select all
GRID_BOTTOM_WIDTH = 768 GRID_TOP_WIDTH = 384 GRID_BOTTOM_XI = 16 GRID_BOTTOM_YI = 472 GRID_BOTTOM_XF = GRID_BOTTOM_XI + GRID_BOTTOM_WIDTH GRID_BOTTOM_YF = GRID_BOTTOM_YI GRID_TOP_XI = ((GRID_BOTTOM_WIDTH - GRID_TOP_WIDTH) / 2) + GRID_BOTTOM_XI GRID_TOP_YI = 256 GRID_TOP_XF = GRID_TOP_XI + GRID_TOP_WIDTH GRID_TOP_YF = GRID_TOP_YI GRID_SIZE = 6 GRID_BOTTOM_STEP = GRID_BOTTOM_WIDTH / GRID_SIZE GRID_TOP_STEP = GRID_TOP_WIDTH / GRID_SIZE ... love.graphics.line(GRID_BOTTOM_XI, GRID_BOTTOM_YI, GRID_BOTTOM_XF, GRID_BOTTOM_YF) love.graphics.line(GRID_TOP_XI, GRID_TOP_YI, GRID_TOP_XF, GRID_TOP_YF) -- Verticle lines for i = 0, GRID_SIZE do love.graphics.line(GRID_BOTTOM_XI + (GRID_BOTTOM_STEP * i), GRID_BOTTOM_YI, GRID_TOP_XI + (GRID_TOP_STEP * i), GRID_TOP_YI) end
There is one possibly good technique where first you find the center of the grid. This is done by finding the intersection of the two lines that form an 'x' over the square. This will give you the y-coordinate, while the x-coordinate can possibly be found by doing stuff with the slopes of the outermost vertical lines. Then you split the square into two halves at this line and recurse on them. I hope that wasn't too vague. This approach can only give a number of lines equal to a power of 2, which may be too many.
I was thinking of using some quadratic formula for the horizontal line spacing. But then I need to invent a quadratic formula.