Drawing a textured line

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
User avatar
Madrayken
Party member
Posts: 126
Joined: Sun May 04, 2014 4:21 pm
Location: Oakland CA
Contact:

Drawing a textured line

Post by Madrayken »

Hi folks,
Moonring is coming along nicely, and I've started doing complex stuff like making bosses 'link' to other creatures you have to kill before you can hurt them.

One of the things I required for this was an 'animating textured line with thickness'. I've horribly abused the drawImage so far, and am literally just angling and stretching an image to the appropriate scale. BUT! Of course, what happens is that at most lengths, the texture is horribly squashed or stretched.

I was trying to think of the easiest, neatest way of drawing a line with a texture that repeats and does not stretch. I can't think of any way apart from doing something with multiple quads, or diving into drawing of a primitive, complete with horrible rotation of uvs. Is this true, or has someone else found a nice, neat way to draw a line using a texture aligned appropriately etc.?
Discord: https://discord.gg/tYfHgXc
Bandcamp: https://madrayken.bandcamp.com/
Twitter: @Fluttermind
User avatar
Xii
Party member
Posts: 137
Joined: Thu Aug 13, 2020 9:09 pm
Contact:

Re: Drawing a textured line

Post by Xii »

You can have the texture as its own texture (not part of an atlas), and repeat it by using texture coordinates larger than the texture itself.
When you love.graphics.newQuad() you pass the width and height of the quad in the texture. Pass in values greater than the texture's width or height, and you'll get repetition.
User avatar
Madrayken
Party member
Posts: 126
Joined: Sun May 04, 2014 4:21 pm
Location: Oakland CA
Contact:

Re: Drawing a textured line

Post by Madrayken »

Thanks! I forgot you can rotate UVs on quads. Wait... I don't need to, do I. I'm being a dumbass... :-)
Discord: https://discord.gg/tYfHgXc
Bandcamp: https://madrayken.bandcamp.com/
Twitter: @Fluttermind
Post Reply

Who is online

Users browsing this forum: No registered users and 51 guests