Page 1 of 1

Drawing a tilemap on a canvas, problem with culling.

Posted: Sun Aug 10, 2014 8:36 am
by Moonkis
I'm currently participating in the gbjam3, and so far it's going pretty good. To get the scaling smooth (with no gap between tiles or the like) I'm drawing everything to a canvas, then scaling and translating it by the cameras origin.

The problem is that I'm not sure how to get the culling to work, I know how to calculate the range of tiles to draw, but it seems love.graphics.translate(dx,dy) also translates the canvas, which means it futile to draw to it. I can't seem to move the canvas either so I'm not sure what to do :/

Anyone know how to keep the canvas inside of the view?

Re: Drawing a tilemap on a canvas, problem with culling.

Posted: Sun Aug 10, 2014 10:48 am
by OmarShehata
I'm not sure if I perfectly understand the set up you have, but you could translate back before you draw the canvas, that should work.

Or use love.graphics.push/pop to save a state and revert back to it. http://www.love2d.org/wiki/love.graphics.push

If you can upload a .love file we could offer more help!

Re: Drawing a tilemap on a canvas, problem with culling.

Posted: Mon Aug 11, 2014 7:04 pm
by Jasoco
You need to pop it back before drawing the canvas yes.