Hi, ive been working on a turn-based strategy game which uses a tile map. i wrote my own map&tile classes and was looking for a efficient way to display multiple layers of objects on the map. My first attempt to do this was by simply drawing the images on top of each other, which was fine but turned out to be slow.
So i figured if i build an image for each tile once on the first run through the render loop, and then use this on later on it should be a lot faster (since the map really doesnt change too often, and if, i can call a method to build that image for the one tile that changed).
I looked through
http://slick.cokeandcode.com/wiki/doku. ... o_an_image and some posts on the topic here in the forum how to do it and tried it myself in different approaches but rendering to the graphics context of an image just doesnt seem to work for me. Heres an example of the code i used for building the image:
Graphics b=Init_game.spriteBuffer;
Graphics.setCurrent(b);
b.clear();
b.drawImage(ground.getImage(),0,0);
if (road!=null) b.drawImage(t.road.getImage(),0,0);
wholeImage=Init_game.imgStack;
b.flush();
Where Init_game is a gamestate that declares imgStack as a empty 40,40 sprite and builds spriteBuffer as its context with imgStack.getGraphics.
The part that doesnt work is the part where the drawing into the context of the image should take place, it just returns a blank black piece.