Page 1 of 1

table not visible?

Posted: Tue Jul 06, 2010 1:35 pm
by vschiavoni
Hello
im getting started with LOVE. I did a simple script that is supposed to draw 10 circles at random positions on the scree.
I initialize the coordinates in load.love(), and I try to draw them in load.love() .

When I run the app, the window and the background are displayed, but not circles.
What am I doing wrong?

Code: Select all

peers={}
function love.load()
	love.graphics.setBackgroundColor( 2, 60, 80 )
	for i,v in ipairs(peers) do
		local x = math.random(1024)
		local y = math.random(768)
		peers[i] = {x,y}
	end	
end
function love.draw()
	for _,p in pairs(peers) do
	 	 love.graphics.circle("line", p[1], p[2], 10, 100) 
	end
end

Re: table not visible?

Posted: Tue Jul 06, 2010 2:38 pm
by bartbes
Ehm, how is the table supposed to be filled?
ipairs loops over the existing entries in the table, these don't exist so the loop simply never runs.

Re: table not visible?

Posted: Tue Jul 06, 2010 3:02 pm
by vschiavoni
The table is filled in the love.load(). See the code i've posted this line:

Code: Select all

peers[i] = {x,y}

Re: table not visible?

Posted: Tue Jul 06, 2010 3:07 pm
by bartbes
No it is not, look at the loop again.

Re: table not visible?

Posted: Tue Jul 06, 2010 3:14 pm
by vschiavoni
you're right..i really need one more pair of eyes..

:brows: