Page 1 of 1

grid sample

Posted: Tue Apr 15, 2014 1:47 am
by elsalvador
i took the grid-collision sample from love2d tutorials
and i changed this:

Code: Select all

love.graphics.rectangle("line", x * 32, y * 32, 32, 32)
to this:

Code: Select all

 love.graphics.rectangle("fill", (x-1) * 32 , (y-1) * 32,  32, 32)
and now nothing its accurate??? WHY :( what did I do wrong??

HERE:

Re: grid sample

Posted: Tue Apr 15, 2014 2:05 am
by Karai17
Because you are only drawing the rectangles as offsets, the data is still the same. You will also need to offset the "player" square, too.

Re: grid sample

Posted: Tue Apr 15, 2014 3:27 am
by elsalvador
ugh..
confuse now!

Re: grid sample

Posted: Tue Apr 15, 2014 4:27 am
by Karai17
Well, let's say x = 5. What you're saying is "draw the 5th x where the 4th x is", and so on. Player is still being drawn where it is located, so the map is shifted left while Player isn't.

Re: grid sample

Posted: Wed Apr 16, 2014 3:34 pm
by pielago
okay get it..
now question what if the player its not the same as the grid? will still work?
i see grid cells are the same as the player 32x32 but what if the player its idk 50x100 ??
will the grid still work or is there another way and if so can someone point me to it????? :awesome:
beside grids but the same idea like grids :)

Re: grid sample

Posted: Wed Apr 16, 2014 3:41 pm
by Karai17
You'll want everything to use the same offset, regardless of size.

Re: grid sample

Posted: Thu Apr 17, 2014 3:49 am
by pielago
i can tell your good at it well i will try and if cant ... ill sure message you :) if you don't mind :)

Re: grid sample

Posted: Thu Apr 17, 2014 4:08 am
by Karai17
After building a library to do all of this, I'd like to think I know what I am doing. ;D