Use double buffering.

Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com>
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
main
sigonasr2 3 years ago
parent 7f2bbb855b
commit dec88d32f5
  1. 2
      runGame.command
  2. 2
      runGame.ps1
  3. 2
      runGame.sh
  4. 2
      sig
  5. 1
      src/sig/RabiClone.java
  6. 4
      src/sig/engine/Panel.java

@ -1,3 +1,3 @@
cd bin cd bin
java -Djava.library.path="../lib" -Dsun.java2d.opengl=true -Xms2G -Xmx2G -jar RabiClone.jar java -Djava.library.path="../lib" -Xms2G -Xmx2G -jar RabiClone.jar
cd .. cd ..

@ -1,3 +1,3 @@
cd bin cd bin
java "-Djava.library.path=../lib" "-Dsun.java2d.opengl=true" -Xms2G -Xmx2G -jar RabiClone.jar java "-Djava.library.path=../lib" -Xms2G -Xmx2G -jar RabiClone.jar
cd .. cd ..

@ -1,3 +1,3 @@
cd bin cd bin
java -Dsun.java2d.opengl=true -Djava.library.path="../lib" -Xms2G -Xmx2G -jar RabiClone.jar java -Djava.library.path="../lib" -Xms2G -Xmx2G -jar RabiClone.jar
cd .. cd ..

2
sig

@ -8,7 +8,7 @@ define MAIN_CLASS "sig.${PROJECT_NAME}"
define OUT_DIR "bin" define OUT_DIR "bin"
define LIBRARY_PATH "../lib" define LIBRARY_PATH "../lib"
define CLASS_PATH "${PROJECT_DIR}/..:lib/bin" define CLASS_PATH "${PROJECT_DIR}/..:lib/bin"
define CUSTOM_PARAMS "-Xmx2G -Xms2G -Dsun.java2d.opengl=true" define CUSTOM_PARAMS "-Xmx2G -Xms2G"
define LANGUAGE "Java" define LANGUAGE "Java"
source utils/main.sh source utils/main.sh

@ -80,6 +80,7 @@ public class RabiClone {
(int) ((Toolkit.getDefaultToolkit().getScreenSize().getHeight() - f.getHeight()) / 2)); (int) ((Toolkit.getDefaultToolkit().getScreenSize().getHeight() - f.getHeight()) / 2));
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true); f.setVisible(true);
f.createBufferStrategy(2);
OBJ.add(level_renderer = new LevelRenderer(p)); OBJ.add(level_renderer = new LevelRenderer(p));
StartGame(); StartGame();

@ -194,13 +194,13 @@ public class Panel extends JPanel implements Runnable,KeyListener {
@Override @Override
public void paintComponent(Graphics g) { public void paintComponent(Graphics g) {
super.paintComponent(g); super.paintComponent(RabiClone.f.getBufferStrategy().getDrawGraphics());
// perform draws on pixels // perform draws on pixels
render(); render();
// ask ImageProducer to update image // ask ImageProducer to update image
mImageProducer.newPixels(); mImageProducer.newPixels();
// draw it on panel // draw it on panel
g.drawImage(this.imageBuffer,0,0,getWidth(),getHeight(),0,0,RabiClone.BASE_WIDTH,RabiClone.BASE_HEIGHT,this); RabiClone.f.getBufferStrategy().getDrawGraphics().drawImage(this.imageBuffer,0,0,getWidth(),getHeight(),0,0,RabiClone.BASE_WIDTH,RabiClone.BASE_HEIGHT,this);
updateFPSCounter(); updateFPSCounter();
} }

Loading…
Cancel
Save