performance question

Hi
I’m programmig a 2d game and i use a big background image as my map. I use the BufferedImage.getRGB(int x, int y) method to get data from my map. I want to transfer the data from the image to some other place where i can access the data faster. The question is which method is the best. I was thinking to use a treemap but i am not sure. Can somone help me please, and also show me te code to do it please

Thanks in advance

I have nothing else to say but that using a large image as a map for your game may give you very bad performance! You should look into other solutions like LWJGL (my personal favourite) or Java3d (hi Herkules :).

Hey darcone is right, using one large image for the background is never going to be fast.
Try to break up the image into tiles. Its much quicker to render the visible set of tiles.

Check out http://www.gamedev.net/reference/articles/article743.asp
explains how to do smooth scrolling over the tiles.

http://www.gamedev.net/community/forums/topic.asp?topic_id=65858

Its a reply from the same author, about smooth scrolling.
different code from the article. This cleared it up perfectly for me. Now working sweet ! :slight_smile: