Thursday, October 26, 2006

Spritesheets partially working...

I've done quite some work on the spritesheets(Which took me ~3 to 4 hours, where I could have done it in 1, IF I wouldn't be distracted all the time).

The individual subsheets work, in the sense of: You can add new textures to it, it finds a suitable location(If any), reserve it, and then copy it actual bytes onto the main texture.

Right now, I need to work on the main sheet, which should create a large texture depending on the total video ram(The less ram, the smaller the texture), and I'll add a constructor where you can specify the sizes of the sheet. Then I need to add in code to automatically create new subsheets(If there is any space left on the larger sheet of course) when there are no more free blocks in any subsheet, or when an image is bigger than any cell size currently allocated.

I'm not sure what to do IF there isn't any space left for new subsheets and it requires a cellsize not yet allocated. I technically could search all the subsheets for the largest used block size, attempt to put it in there, and if not, find the next largest cell size, etc. If none of the subsheets can house the texture, an exception should be thrown, and the TextureManager should either attempt to spawn another SpriteSheet or give up.

I'm currently using the default size of 256x256 subsheets, so it's highly inadviseable to use a sprite that's any larger than that. Ofcourse, it'd be a weird sprite if it's that big. For animated sprites, you just as well cut them up in smaller ones and load those.

1 comment:

Anonymous said...

pictars!!!