File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Game Development and the fly likes Flickering Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Game Development
Bookmark "Flickering" Watch "Flickering" New topic
Author

Flickering

Tomm Schuman
Greenhorn

Joined: Mar 04, 2005
Posts: 11
I am making a game.
You can try what i have done so far here

But i have some problems about flickering in the game.
First one is when the frames of the player are drawn the first time it flickers alot. I have no idea why it does that because i load all the images when the game starts.

Then the other problem is when I draw the background which consists of many 20X20 pictures. If i have the game like 500x500 it works good but if i have it 1000x1000 it flickers in the lower right corner. Here is the code i use to paint the background:


I use this for painting:

Is there something wrong in painting this way. I have modified my game from a pacman tutorial which had painting done this way.
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
You'll have to implement double buffering for your display code, maybe even triple buffering if things get really complicated.


42
Tomm Schuman
Greenhorn

Joined: Mar 04, 2005
Posts: 11
But I am using double buffering, how should i add triple buffering?
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Moving to Game Development...


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

I have a few ideas that may help out here...

First, at what rate are you refreshing the screen? Do you have a set Thread.sleep() time? From a while back I remember that a refresh of around 80 ms was OK (for the machine I was on), but that anything faster would flicker because it was just trying to refresh too fast...

Second, could be a separate threading problem if you are using multiple threads to control your game...

Third, it could be that 1000x1000 is just *too big* to be refreshed quickly enough without artifacts... in this case you'll either have to change your game architecture to be "quicker" (changing the redraw so it doesn't redraw the whole screen every time, but keeps track of "dirty" areas and only redraws those) or use libraries that let you get "closer to the metal" like JOGL or LWJGL.


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Flickering