Java Game Programming for Beginners - #3 - Double Buffering

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
4,275
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Jul 25, 2011

Java Game Programming for Beginners - #3 - Double Buffering - Thanks for watching and please ask any questions you may have in the comments below or send me a message! Remember to subscribe and thanks for your support!

Category:

Education

Tags:

License:

Standard YouTube License

  • likes, 0 dislikes

Link to this comment:

Share to:

Uploader Comments (TheJavaHub)

  • I don't get the usage of Public and Private, In the video you declared dbImage to be private.As far as I understand it doesn't matter unless you are going to access it from another class.So my question is why not to declare every thing as public?

  • @Mrkirill578 'private' means that you cannot access the variable/method/class from outside the class it is within. This is to protect the variables from unwanted changes. 'public' allows the variable/method/class to be accessed from anywhere outside the class it is within. The reason we use private for the dbImage and dbg is because if it were to be modified from a different Thread, for example, the program would crash.

  • (-_-)

    

  • @TarbleSs1 ???

  • Double buffering is so confusing for me :( I understand when you talk about it and show it.. but doing it myself is so much harder >_<.

  • @TheJavaHub @CriticaLKonflict ways in this video. Double buffering works because instead of deleting the entire image and then repainting it, we 'pre-load' the next image off the screen and then paint it directly to it. This prevents the annoying flickering.

    Hope this helps :)

see all

All Comments (37)

Sign In or Sign Up now to post a comment!
  • OMG it works perfect! Ive been learning java for a few days and workin on my side scroller was really trouble until i saw this! I <3 you man, no homo. hahah :) Thanks!

  • OK, now it is fine. It seems like it had some problems with jre6, what do you think it could be ?

  • I work in eclipse and did everything like you did, I hava the same number of warnings on keys like you, but it won't run, it says in the console: java.lang.NoSuchMethodError: main

  • @TheJavaHub this is a somewhat better explanation because I'm having trouble interpreting the changes to the image line by line in the code. It would be cool if there was a step-by-step visual explanation to what's going on as the loop happens

  • for some reason the program dose not even start

  • Anyone know how to work with a gui in netbeans? how would you make say a character move across the screen with this code?

  • i m getting an error in this:

    public void paint(Graphics g) { dbimage = createImage(getWidth(), getHeight()); dbg = dbimage.getGraphics(); paintComponent(dbg); g.drawImage(dbg, 0, 0, this); }

    the g.drawImage(dbg, 0, 0, this); encounters an error, that is:

    "The method drawImage(Image, int, int, ImageObserver) in the type Graphics is not applicable for the arguments (Graphics, int, int, javaGame)"

  • thanks a lot for this tutorial it helped a lot! :-)

Loading...

Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more