anyone have made any efficient smooth background scroller?
i have tried three method to make a 1440 x 1216 background that could scrolled
constructed with many 32x32 tiles
first, the easiest one, i make a big image 1440 x 1216 large, put all tiles in initialize
then scroll it with g.drawImage(image, -x, -y, null);
takes 40% cpu usage with 46,850K memory consumptions
second (i used now) i create a 640 x 480 image (as large as the resolution)
and each frame, i scan and put the tiles into the images
imageGraphics.drawImage(tiles[pos], x, y, null);
then i put the image into screen g.drawImage(image, 0, 0, null);
takes 70% cpu usage with 34,680K memory consumptions
and the last, i create a 640 x 480 image and then fill it with
grass tile (the basic tile) in initialize and put the image
g.drawImage(image, 0, 0, null);
then scan through all the tiles whereas the tile different from the grass i put it with
g.drawImage(differentTiles, x, y, null);
not implemented yet
the first takes too large memory
(every changing the background it takes about 10megs memory consumptions increment)
the second takes too many cpu time, make the fps drops.
(cos with 640 x 480 large cause the tiles drawn 640/32 = 20 for horizontal scanning and
480/20 = 15 for vertical and the result 300 tiles must be drawn every frame)
the last one is the best one, but i haven’t got the point
only drawing grass tiles takes 40% cpu usage with 37,932K memory consumptions
all method i observe in windows xp with windowed mode,
using volatile image (passive rendering), and
the result same as using buffer strategy (active rendering)
and the image is png files using BufferedImage
so what’s the best way to do this??
thanxx in advance ;D