Using LWJGL and Slick2d, how do I load up a large image(sprite sheet) and store it into smaller images?
I have done a little bit of basic stuff, I can tiles a grass tile across the screen evenly, I can display a transparent texture to the screen but I can't seem to find any documentation on loading sprites from a larger sprite sheet.
How would I dice the image up into smaller images? Or is there a different way to do it?
There is a SpriteSheet class in Slick that does exactly this.
SpriteSheets, in Slick, are large images made up of a series of uniformly sized tiles. Each tile is typically an animation frame in a Sprite. In the SpriteSheet constructor you specify the image (which has all the tiles), and the width/height of the tiles in the sheet, along with any spacing and margin, if you have/need that.
Finally, the getSprite(x, y) method allows you to retrieve the specified tile, as if it were an element in a 2D array. In other words, if you have a SpriteSheet of 16 tiles, that are arranged in a 4x4 grid of tiles, then to get the tile in column 3, row 2, you would call getSprite(3, 2);
I believe the indexes in getSprite(x, y) are zero-based, just like arrays in Java.