Page 1 of 1

This is the first real problem I've run into...

Posted: Sat Jan 09, 2010 8:26 am
by Fourex
So, I'm trying to create a simple tile map. I have this:

Code: Select all

z = { {0, 0, 1, 0, 0, 0, 0, 1, 0, 0},
		{0, 0, 1, 0, 0, 0, 0, 1, 0, 0},
		{0, 0, 1, 0, 0, 0, 0, 1, 0, 0},
		{0, 0, 1, 0, 0, 0, 0, 1, 0, 0},
		{2, 2, 3, 0, 0, 0, 0, 1, 0, 0},
		{0, 0, 0, 0, 0, 0, 0, 1, 0, 0},
		{2, 2, 2, 2, 2, 2, 2, 3, 0, 0},
		{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
		{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
		{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
	}
grass = love.graphics.newImage("grass.png")
vert = love.graphics.newImage("vertpath.png")
horz = love.graphics.newImage("horzpath.png")
UL = love.graphics.newImage("U/Lpath.png")

love.graphics.setMode( 160, 160, false, true, 0 )
love.graphics.setCaption( "Tiles" )
				
function love.draw()
	for i, v in ipairs(z) do
		for j, w in ipairs(z[i]) do
			if w==0 then
				love.graphics.draw(grass, j*16, i*16)
			elseif w==1 then
				love.graphics.draw(vert, j*16, i*16)
			elseif w==2 then
				love.graphics.draw(horz, j*16, i*16)
			elseif w==3 then
				love.graphics.draw(UL, j*16, i*16)
			end
		end
	end

end
It should be 10x10 tiles. (all the image files are 16x16, and the window is set to 160, 160)
When I run this, Love opens, the screen is completely grey for a few seconds, then Love quits. I'm on a Mac, if that helps.
One thousand internets to whoever can help me.

Re: This is the first real problem I've run into...

Posted: Sat Jan 09, 2010 4:30 pm
by Robin
That's.. odd.

Does removing the setMode/setCaption change anything? (if you still want to use them, take a look at http://love2d.org/docs/conf_lua.html)

Re: This is the first real problem I've run into...

Posted: Sat Jan 09, 2010 5:30 pm
by bartbes
Yes, it might be something to do with the way you are creating your screen, you might want to move it to conf.lua. (normally the screen is set up after loading main.lua and before running love.load)

Re: This is the first real problem I've run into...

Posted: Sat Jan 09, 2010 5:48 pm
by Fourex
So, I tried shortening up my code by using another table for the tiles, and that didn't work. And I tried doing all the window stuff before love.load with the love.conf, but it still won't work. :ehem:
Here's my code:

Code: Select all

function love.conf(t)
    t.screen.height = 160
    t.screen.width = 160
    t.title = "Tiles"  
end

function love.load()
	map ={{1, 1, 2, 1, 1, 1, 1, 2, 1, 1},
			{1, 1, 2, 1, 1, 1, 1, 2, 1, 1},
			{1, 1, 2, 1, 1, 1, 1, 2, 1, 1},
			{1, 1, 2, 1, 1, 1, 1, 2, 1, 1},
			{3, 3, 4, 1, 1, 1, 1, 2, 1, 1},
			{1, 1, 1, 1, 1, 1, 1, 2, 1, 1},
			{3, 3, 3, 3, 3, 3, 3, 4, 1, 1},
			{1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
			{1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
			{1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
		}
	grass = love.graphics.newImage("grass.png")
	vert = love.graphics.newImage("vertpath.png")
	horz = love.graphics.newImage("horzpath.png")
	UL = love.graphics.newImage("U/Lpath.png")
	
	tiles =	{grass, vert, horz, UL}
end
				
function love.draw()
	for i, v in ipairs(map) do
		for j, w in ipairs(map[i]) do
			love.graphics.draw(tiles[w], j*16, i*16)
		end
	end

end

Re: This is the first real problem I've run into...

Posted: Sat Jan 09, 2010 5:53 pm
by Robin
Works for me. Are you sure you have the images in the right place?

Re: This is the first real problem I've run into...

Posted: Sat Jan 09, 2010 6:36 pm
by Fourex
Yup, all the images are in the folder with main.lau. Maybe Löve has issues with .png files? I could convert the images to pretty much any filetype.

Re: This is the first real problem I've run into...

Posted: Sat Jan 09, 2010 6:55 pm
by bartbes
I think the problem is U/Lpath.png, there can't be a / in a filename. Though when you put it in love.load it should at least display you the error.., well, I just thought up a situation where this isn't the case. Let me check that and get back to you.

EDIT: yes, apparently file-not-found errors aren't caught and thus LÖVE crashes hard, I'll put it on the bug tracker.

Re: This is the first real problem I've run into...

Posted: Sat Jan 09, 2010 7:12 pm
by Fourex
Thank you!!