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

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
Fourex
Citizen
Posts: 53
Joined: Tue Nov 10, 2009 2:33 am
Location: Earth

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

Post 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.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

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

Post 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)
Help us help you: attach a .love.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

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

Post 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)
User avatar
Fourex
Citizen
Posts: 53
Joined: Tue Nov 10, 2009 2:33 am
Location: Earth

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

Post 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
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

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

Post by Robin »

Works for me. Are you sure you have the images in the right place?
Help us help you: attach a .love.
User avatar
Fourex
Citizen
Posts: 53
Joined: Tue Nov 10, 2009 2:33 am
Location: Earth

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

Post 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.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

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

Post 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.
User avatar
Fourex
Citizen
Posts: 53
Joined: Tue Nov 10, 2009 2:33 am
Location: Earth

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

Post by Fourex »

Thank you!!
Post Reply

Who is online

Users browsing this forum: Guglio, Koeba and 1 guest