1 2 Previous Next 19 Replies Latest reply: Mar 11, 2010 7:55 AM by 843853 Go to original post RSS
      • 15. Re: Flickering only in the beginning
        843853
        If that part is redundant, how can I get the g object for drawing? I'll research it. It's ironic that the flicker occurs in the supposedly cheapest part of the game, talking in CPU time. It makes me doubt about
        Any code in your draw that does not have to do with actually displaying the image on the screen needs to be removed
        Although I'll research about the bufferedImage stuff
        • 16. Re: Flickering only in the beginning
          843853
          What I'm seeing is that you are trying to do some type of active rendering and not being very successful at getting it to do so without flicker. The flicker is brought about by overrunning your dead time between screen writes, or by clearing and then taking too long to write your graphics. This should be elevated by using SWING as the SWING components are double buffered by default. What you are doing still remains a mystery to me as you have not provided graphics execution path code, just snippets. In animation you are literally multitasking fast enough to fool the eye, but in the case of flicker, you're illusion is breaking down because the writes to the screen as prolonged by sluggish routines. The animation portion of your routines have to be very tight in order to sustain the illusion.

          Edited by: morgalr on Mar 9, 2010 6:51 PM -- the follwing added:

          You get your gaphics object by doing a: getGraphics() or createGraphics on your display component.
          • 17. Re: Flickering only in the beginning
            843853
            Sorry, I don't understand what is the graphics execution path, I'm ignorant in many aspects of the java drawing. I have to leave, tomorrow I'll post when I have learned what is it. Regards
            • 18. Re: Flickering only in the beginning
              843853
              Morgalr, I've been researching about the "canonical" way of drawing in java, and I found that the code I have isn't very good because I'm drawing constantly all the elements in the scene. I'm changing my program (bufferedimages, override paint method of the panel class, etc), I'll post this evening and I tell you, but I'm optimistic regarding to this
              • 19. Re: Flickering only in the beginning
                843853
                Finally, the game runs properly! It never flickers. The key have been the points that I posted yesterday:

                * Using the JPanel class and its draw method
                * Using BufferedImages instead Images
                * Refreshing the screen only with the necessary items, and only when it's necessary
                * Using the swing.timer

                I have achieved no flickering putting all together. Still I haven't finished the game, but I'm sure yet that the flickering will never be produced. Thanks a lot for your help, regards:

                Alejandro
                1 2 Previous Next