• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Flickering

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You'll have to implement double buffering for your display code, maybe even triple buffering if things get really complicated.
 
Tomm Schuman
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But I am using double buffering, how should i add triple buffering?
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to Game Development...
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
You would be much easier to understand if you took that bucket off of your head. And that goes for the tiny ad too!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic