Archived

This topic is now archived and is closed to further replies.

Silly_con

Smooth Scrolling

Recommended Posts

I am making a 2d game in java, with 2 background planes, but when I make the scroll of this planes, adding or subtracting n units in the x coordinate (the near background moves faster than the far background plane) the scroll is not smooth, like in the comercial games, how I can do it smooth?

Share this post


Link to post
Share on other sites
I can think of a couple things:
(1) Use time-based movement. It may be that your framerate is just too low for the effect to work, so you are moving the layers too fast.

(2) Slow things down a bit...move the front layer back in 3d space so that it moves slower.

(3) Blur the faster moving layer- may not help much...but worth a try if all else fails.

If you have any issues with my answers...post an applet or some code so I can look at it.


Brian J
DL Vacuum - A media file organizer I made | Mumbling Miles - A band I was the guitarist/vocalist for

Share this post


Link to post
Share on other sites
the code is something like:

// in applet init
Image layer1 = getImage(...,"layer1.gif");
Image layer2 = getImage(...,"layer2.gif");

// in applet paint
g.drawImage(layer1,layer1_x,layer1_y,..);
g.drawImage(layer2,layer2_x,layer2_y,..);

// in main loop
offset = 10;

if (rightPressed) { layer1_x -= offset; layer2_x -= offset/2; }
if (leftPressed) { layer1_x += offset; layer2_x += offset/2; }

repaint();

Share this post


Link to post
Share on other sites
Set the offset lower...that will definately make it smoother, but also slower. I can''t tell you anything else except to increase your FPS. If you have some sort of timer or something that limits the framerate, try lowering the time between frames.

Share this post


Link to post
Share on other sites