I'm guessing you're using Slick-Util?
Improve performance by placing all your tiles into the same texture (aka a sprite sheet), and then draw a textured quad using proper texcoords. Code example:
http://pastebin.java-gaming.org/54a6b7d54Then the in-game code would look like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| public void init() { sheet = new Image2D(sheetTexture); tileGrass = sheet.getSubImage(...); tileDirt = sheet.getSubImage(...); tileWater = sheet.getSubImage(...); }
public void render() { sheet.begin(); for (int x=0; x<mapWidth; x++) { for (int y=0; y<mapHeight; y++) { Image2D img = getImageForTile( map[x][y] ); img.draw( x * TILESIZE, y * TILESIZE ); } } sheet.end(); } |