Flickering scrolling backgrounds

I’ve implemented a parallax scrolling layer in my 2D applet-gameengine and everything behaives as I’d like it to except for the fact that the background flickers!

The flickering seems to be proportional to the size of the backgroundimage (which is just a big image that i move to achieve the scrolling).

I’m using the BufferStrategy with 4 buffers but it looks the same as when I had 2…

Am I out in the woods about scrolling or is there some trick out there that I don’t know about?

/Markus

OK, the word parallax is really scaring me. Could you explain what that is? Also, could you explain a few more details about your BufferStrategy? Are you working exclusively in windowed mode or full screen mode? Are you using BufferStrategy with a Frame or a Canvas? Are you using VolatileImages or ManagedImages? I’ve scrolled some pretty large images in windowed mode using a BufferStrategy of 3 buffers in just a regular Canvas object without flicker, so I know it works. I’ll admit I know nothing about using applet’s or their abilities, so forgive me if I’ve asked stupid questions.

[quote]OK, the word parallax is really scaring me. Could you explain what that is?
[/quote]
Parallax refers to the effect of depth on multiple layers. Typically in a game (say a platformer) you’ll have your main layer (characters, platforms etc.) and a couple of background ones (eg. one for trees & details, one for sky). By scrolling those further away at a slower speed you create an illusion of depth.

Odds are you’re getting some sort of AWT/Swing repaint event kicking in while you’re trying to do your own drawing. I think theres something like .setIgnoreRepaint() you need to add if you’ve not already. The type of image you’re using shouldn’t matter, but the actual drawing surface and how you’re handling drawing (active rendering or drawing in response to .repaint events) does.

[quote] Parallax refers to the effect of depth on multiple layers
[/quote]
OK, not so scary. Thanks for the explanation. :slight_smile:

Ok… I’m using window mode BufferStrategy with 2 (or 4 - doesn’t matter) buffers an a Canvas. I’ve set the ignoreRepaint false on the canvas but still get a flickering feeling. The faster I scroll, the more flicker I get ( combined with the impact of the size of the image).

I load the images as managed images and not Volatile. AFAIK VolatileImages magic is the ability to have a accelerated Graphics objc connected to it, hence it should be used for your own backbuffers so that one can render managed images on it? Correct me if I’m wrong :wink:

[quote]still get a flickering feeling
[/quote]
Are you using some kind of animation loop? And if so, are you using a high resolution timer? If the answer is yes to both (or even if it isn’t) perhaps you’re hitting the limits of your hardware. I don’t know, just trying to throw out some ideas.

[quote] I load the images as managed images and not Volatile. AFAIK VolatileImages magic is the ability to have a accelerated Graphics objc connected to it, hence it should be used for your own backbuffers so that one can render managed images on it?
[/quote]
I’ve got it in my head that accelerated managed images use some form of VolatileImages and BufferStrategy uses VolatileImages for it’s backbuffers automagically, and their use in those situations is intended to be a black box and hidden from the user, i.e. ManagedImages will “take care of it for you” as far as hardware acceleration goes. And using a VolatileImage allows you to have more control over things and a very slight speed increase over using managed images at the expense of some features such as hardware accelerated translucency. Thus, I don’t see any problem using either managed images of volatile images if they both fit your needs. In fact, I would experiment with both. I have found that, depending on the hardware, one sometimes works better than the other slightly.

Er… is that a typo or what you’re genuinly doing? If you’ve got your own game/drawing loop doing the painting then this need to be setIgnoreRepaint(true).

Sorry - Big typo… :-[

I mean (natuarlly) setIgnoreRepaint(true)