> What if that's not a good idea, because for example you want to load a huge image once (with 10,000 tiles)?
I believe it is documented that #load_tiles can take either a filename or a RMagick instance. However, I believe that in Gosu RMagick instances and Gosu::Image instances are interchangeable. Thus, you can load the whole spritesheet into memory first and then split it.
The code would be something like this.
spritesheet = Gosu::Image.new($window, path_to_file, false)
sprite_array = Gosu::Image::load_tiles($window, spritesheet, width, height, false)
I can confirm that this works, as it is how I am doing it. However, I'm only doing it this way because I need to composite multiple images into a single spritesheet, and divide the resultant image into tiles.
However, if you're loading that much into memory at once, I would say that you have a problem. I would suggest loading only what you need into memory, and thus storing the spritesheet in smaller chunks. However, reading from the disk is quite slow... so I guess it's more of a personal choice. I personally don't like it when apps take more memory than then need though. I imagine that 10,000 tiles would take up a good deal of memory, however.
Once you get used to the flow of Gosu I believe you will see that it is better (ie more intuitive) to chop up an image into sprites/tiles and draw those. I am assuming you're new to the engine as you are new to the forum. Please excuse me if I am mistaken.
> I wouldn't think that using ... would be a good idea
Yeah, I would advise against that as it looks unwieldy, and it is probably going to be slow. However, if you really want a similar feel, you could take the array generated from #load_tiles and parse the elements into a hash with the keys being related to the position of the tile in the overall spritesheet. Although honestly, like I said before, I really don't understand why you would want to do it that way. Feel free to explain it to me though, I am genuinely interested.