Drawq, am I missing something?

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
timmcd
Prole
Posts: 8
Joined: Fri Dec 25, 2009 12:07 am

Drawq, am I missing something?

Post by timmcd » Sat Dec 26, 2009 7:09 am

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
the source and picture
(40.99 KiB) Downloaded 98 times

User avatar
konsumer
Prole
Posts: 7
Joined: Wed Jan 06, 2010 5:16 am

Re: Drawq, am I missing something?

Post by konsumer » Wed Jan 06, 2010 4:42 pm

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.
Attachments
map_loader.love
(16.24 KiB) Downloaded 94 times

osuf oboys
Party member
Posts: 215
Joined: Sun Jan 18, 2009 8:03 pm

Re: Drawq, am I missing something?

Post by osuf oboys » Wed Jan 06, 2010 5:34 pm

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.
If I haven't written anything else, you may assume that my work is released under the LPC License - the LÖVE Community. See http://love2d.org/wiki/index.php?title=LPC_License.

User avatar
konsumer
Prole
Posts: 7
Joined: Wed Jan 06, 2010 5:16 am

Re: Drawq, am I missing something?

Post by konsumer » Wed Jan 06, 2010 5:39 pm

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.
Attachments
mario.zip
(43.77 KiB) Downloaded 86 times

Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests