Page 1 of 1

ARGH! The tiles are distorted.

Posted: Tue Mar 17, 2009 10:46 am
by S-Rave
Lame name for a lame game.

Just because it was so simple and fast to make...
Also, there's some initiation problems :\ or something. This doesn't work:

Code: Select all

map = {
	   img = love.graphics.newImage("gfx/image.png"),
	   tilesx = 5,
	   tilesy = 5,
	}
 	for y = 1, map.tilesy do
 	    for x = 1, map.tilesx do
	    	map[y][x] = (x-1) + (y-1) * map.tilesy
		end
	end
But this does:

Code: Select all

map = {
	   img = love.graphics.newImage("gfx/image.png"),
	   tilesx = 5,
	   tilesy = 5,

	   {0,1,2,3,4},
	   {5,6,7,8,9},
       {10,11,12,13,14},
       {15,16,17,18,19},
       {20,21,22,23,24},
	}
 	for y = 1, map.tilesy do
 	    for x = 1, map.tilesx do
	    	map[y][x] = (x-1) + (y-1) * map.tilesy
		end
	end
Why? :S

Re: ARGH! The tiles are distorted.

Posted: Tue Mar 17, 2009 11:14 am
by whitebear
Because your function needs all arguments. They can't use null for any calculation.

Re: ARGH! The tiles are distorted.

Posted: Tue Mar 17, 2009 12:12 pm
by qubodup
I'm not sure, but perhaps you have to create map[y] before you can create map[y][x]?

Re: ARGH! The tiles are distorted.

Posted: Tue Mar 17, 2009 1:59 pm
by rude
qubodup wrote:I'm not sure, but perhaps you have to create map[y] before you can create map[y][x]?
That's probably it.

Code: Select all

map = {
      img = love.graphics.newImage("gfx/image.png"),
      tilesx = 5,
      tilesy = 5,
   }
   for y = 1, map.tilesy do
       map[y] = {}
       for x = 1, map.tilesx do
          map[y][x] = (x-1) + (y-1) * map.tilesy
      end
   end

Re: ARGH! The tiles are distorted.

Posted: Tue Mar 17, 2009 3:21 pm
by S-Rave
Yes, I was thinking along those lines reading the first post. Gonna try it out when I get home. :)
Thanks! :D

Re: ARGH! The tiles are distorted.

Posted: Tue Mar 17, 2009 3:30 pm
by bartbes
I was about to say the same.. well anyway the game:
I'm not very good at those, so I didn't finish it. But it might be nice if you wrote the correct orientation somewhere, as it might be

Code: Select all

1 2
3 4
5 6
or

Code: Select all

1 4
2 5
3 6
(both just examples)

Re: ARGH! The tiles are distorted.

Posted: Tue Mar 17, 2009 4:36 pm
by S-Rave
Yes, I would have implemented a menu but I'm too lazy. Gonna fix it up when I get home. Just press r to randomize.

*Gonna fix it so that you only have to press r to randomize.