Drawq, am I missing something?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Drawq, am I missing something?
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?
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.
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 169 times
-
- Party member
- Posts: 215
- Joined: Sun Jan 18, 2009 8:03 pm
Re: Drawq, am I missing something?
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.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. :'(
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.
Re: Drawq, am I missing something?
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 161 times
Who is online
Users browsing this forum: Ahrefs [Bot] and 3 guests