First of all, you should check and see how much time is spent on your own code, and how much time is spent on drawing a frame. You may have a bug or crash, which makes it run slower.
You can get much better performance than 98 ms to draw your screen. These game libraries are likely to use the same graphical calls as you. But which containers you use can have a big impact on how quickly things get done. I remember a couple of months ago, working on graphical code with double buffering, and how the backup buffer was created made a huge difference in performance.
In particular, make sure that you only create a background image once, or at least only when resizing the canvas. In my code, I do this:
//create a graphics backplane if(backplane == null || !backplaneSize.equals(this.getSize())){ backplane = this.createImage((int)this.getSize().getWidth(), (int)this.getSize().getHeight()); backplaneSize = this.getSize(); }
Thus, the back plane is created only if it is new, or if the size of the component changes. This has a huge impact on speed.
I am doing graphical programming in java with JDK 1.0. In fact, I never heard of this BufferStrategy thing. Heh.
I have never had problems getting quality frames with basic Java graphics calls. Another thing you need to pay attention to is to make sure that Swing is not trying to clear the background of your component from you. This can be another source of slowdown.
Chad okere
source share