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?
??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.
The risk I took was calculated,
but man, am I bad at math.
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.
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 )
The risk I took was calculated,
but man, am I bad at math.
pgimeno wrote: ↑Sat Apr 17, 2021 10:56 am
A texture atlas is the way to speed it up. SpriteBatch is made mostly for this kind of usage, and requires a texture atlas.
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.
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.
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.
Thnx, that's a nice approach. I'll try it.
The risk I took was calculated,
but man, am I bad at math.