Drawing a tilemap on a canvas, problem with culling.

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Moonkis
Prole
Posts: 14
Joined: Thu Jan 09, 2014 4:37 pm

Drawing a tilemap on a canvas, problem with culling.

Post 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?
User avatar
OmarShehata
Party member
Posts: 259
Joined: Tue May 29, 2012 6:46 pm
Location: Egypt
Contact:

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

Post 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!
User avatar
Jasoco
Inner party member
Posts: 3727
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

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

Post by Jasoco »

You need to pop it back before drawing the canvas yes.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 10 guests