So I could make an atlas of all the tiles used using imagedata, then sort it(?) and then use the sprite batch
...
how?
Efficiently drawing a grid map
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- Gunroar:Cannon()
- Party member
- Posts: 1141
- Joined: Thu Dec 10, 2020 1:57 am
Re: Efficiently drawing a grid map
I've made such spritesheet and used sprites (quads) from it:Gunroar:Cannon() wrote: ↑Sun Apr 18, 2021 1:53 pm So I could make an atlas of all the tiles used using imagedata, then sort it(?) and then use the sprite batch
...
how?
https://love2d.org/forums/viewtopic.php?f=3&t=90857
- Gunroar:Cannon()
- Party member
- Posts: 1141
- Joined: Thu Dec 10, 2020 1:57 am
Re: Efficiently drawing a grid map
??Hmmm... Do you get the pictures individually and then put them in one image data, using the data as a spritsheet for a sprite batch? Because that's what I'm asking for.
Re: Efficiently drawing a grid map
No idea of how your project is structured. But you mentioned a grid, so I imagine that the images to draw in that grid are all of the same size. Create an image whose sides are multiples of the horizontal and vertical size respectively, of the images to include, that is able to fit all the images. Then place each image in the big one, allocating a quad at the same time, e.g. in left-to-right order then the next row and so on. Not sure what's complicated about it.
Finally, instead of drawing images, you draw quads of the big image. Or build a spritebatch, your call. Again, hard to know what's best with just the given info.
If your images are of varied sizes, there are algorithms for creating texture atlases automatically. The idea is the same, except for the row-by-row part. I think there have been libs posted in this forum too. Search.
Finally, instead of drawing images, you draw quads of the big image. Or build a spritebatch, your call. Again, hard to know what's best with just the given info.
If your images are of varied sizes, there are algorithms for creating texture atlases automatically. The idea is the same, except for the row-by-row part. I think there have been libs posted in this forum too. Search.
- Gunroar:Cannon()
- Party member
- Posts: 1141
- Joined: Thu Dec 10, 2020 1:57 am
Re: Efficiently drawing a grid map
They are of the same size, thnx pgimeno, though can't I order it when the map is loaded, if it's just one big map, then just put it into an imagedata(what's up with me and imageData )
Re: Efficiently drawing a grid map
I thought sprite batching became automatic in Love a few versions ago? Am I mistaken about what that meant?
Any code samples/ideas by me should be considered Public Domain (no attribution needed) license unless otherwise stated.
Re: Efficiently drawing a grid map
I mention that later on.
https://love2d.org/forums/viewtopic.php ... 86#p240186
Manual batching is still available. As I mention in that post, I'm not sure whether it improves performance or not.
Re: Efficiently drawing a grid map
Note to self: Get better at reading, lolpgimeno wrote: ↑Mon Apr 19, 2021 7:07 pmI mention that later on.
https://love2d.org/forums/viewtopic.php ... 86#p240186
Manual batching is still available. As I mention in that post, I'm not sure whether it improves performance or not.
Thanks!
Any code samples/ideas by me should be considered Public Domain (no attribution needed) license unless otherwise stated.
Re: Efficiently drawing a grid map
You could draw the whole map to a canvas, and then just draw the canvas each frame. The problem there would likely be texture size, depending on how big your map is. Or you could draw a screenful to a canvas, or slightly more than a screenful to give you a bit of scrolling before you need to redraw.
If you really want to use ImageData rather than Canvas, you can generate ImageData from a Canvas. I'm new to Love myself, so I don't totally understand what the advantages are.
If you really want to use ImageData rather than Canvas, you can generate ImageData from a Canvas. I'm new to Love myself, so I don't totally understand what the advantages are.
- Gunroar:Cannon()
- Party member
- Posts: 1141
- Joined: Thu Dec 10, 2020 1:57 am
Re: Efficiently drawing a grid map
Thnx, that's a nice approach. I'll try it.DrNefario wrote: ↑Tue Apr 20, 2021 11:44 am You could draw the whole map to a canvas, and then just draw the canvas each frame. The problem there would likely be texture size, depending on how big your map is. Or you could draw a screenful to a canvas, or slightly more than a screenful to give you a bit of scrolling before you need to redraw.
If you really want to use ImageData rather than Canvas, you can generate ImageData from a Canvas. I'm new to Love myself, so I don't totally understand what the advantages are.
Who is online
Users browsing this forum: Google [Bot] and 3 guests