Reputation: 1
This piece of code should make a huge grid. I'm trying to make the code efficient so I obviously don't have to keep making lines to form a large grid.
-- Grid Vertical
local gx = 0
-- Grid Horizontal
local gy = 0
-- Grid Loop
local g = 0
while g ~= 100 do
print("Grid Loop: "..g) -- for testing purposes of the loop
love.graphics.line( gx, 0, gx, 500)
love.graphics.setColor( 255, 255, 255 )
love.graphics.line( 0, gy, 1000, gy)
love.graphics.setColor( 255, 255, 255)
local gx=gx+50
local gy=gy+50
g=g+1
end
end
When the program loads it only makes 2 lines at the very top of the GUI. The lines are barely visible but I managed to locate them when changed the line colour to red.
The finished GUI was completely black but I want my screen to look something like this: http://i.gyazo.com/7913c29776ba2248c07e37f3be9b64a4.png
Upvotes: 0
Views: 325
Reputation: 124
remove those local behind gx and gy:
-- Grid Vertical
local gx = 0
-- Grid Horizontal
local gy = 0
-- Grid Loop
local g = 0
while g ~= 100 do
print("Grid Loop: "..g) -- for testing purposes of the loop
love.graphics.line( gx, 0, gx, 500)
love.graphics.setColor( 255, 255, 255 )
love.graphics.line( 0, gy, 1000, gy)
love.graphics.setColor( 255, 255, 255)
gx=gx+50 -- ** there's no need for local
gy=gy+50 -- ** you have these values before WHILE Loop.
g=g+1
end
end
Upvotes: 2