Page 1 of 1
Drawq, am I missing something?
Posted: Sat Dec 26, 2009 7:09 am
by timmcd
I'm trying to use love.graphics.drawq to draw specific tiles from my tileset. Attached is my approach... that doesn't work. I'm not understanding the problem, it _SHOULD_ work. :'(
Re: Drawq, am I missing something?
Posted: Wed Jan 06, 2010 4:42 pm
by konsumer
I have an example that loads
tiled maps. I don't have camera/player moving around stuff working, yet (maybe someone has an idea) but it uses drawq() correctly to draw the maps.
The basic idea is that you make a quad with love.graphics.newQuad() that is the viewport and knows how big the full image is. Then drawq() it, just like it's an image: love.graphics.drawq(YOUR_IMAGE, YOUR_VIEWPORT_QUAD, x, y)
I attached what I have, hopefully it is helpful. The map was saved using the lua plugin for
tiled. I turned off binary mode in the saving options.
Re: Drawq, am I missing something?
Posted: Wed Jan 06, 2010 5:34 pm
by osuf oboys
timmcd wrote:I'm trying to use love.graphics.drawq to draw specific tiles from my tileset. Attached is my approach... that doesn't work. I'm not understanding the problem, it _SHOULD_ work. :'(
drawqtesting.zip
Your tiles are of size 32, not 16. the parameters for newQuad are x, y, width, height. You need to fix the last two parameters. When extending the code to the real application, try not to create new quads every frame; it will use up a lot of memory. Store the quads representing the tiles and use again. This tutorial might also be of interest:
http://love2d.org/wiki/index.php?title= ... _Scrolling.
Re: Drawq, am I missing something?
Posted: Wed Jan 06, 2010 5:39 pm
by konsumer
I liked that tileset (except that it doesn't have proper alpha) and wanted to use the tiled visible property that is built-in, rather then a custom property. See my attached example. I include the tmx file, so you can see how I made it. I have a hidden layer, which contains all the items hiding in blocks, breakable layer, and a collision layer. There is no actual code that uses this info, but you get the idea.