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
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 ..

@ -1,3 +1,3 @@
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 ..

@ -1,3 +1,3 @@
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 ..

2
sig

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

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

@ -194,13 +194,13 @@ public class Panel extends JPanel implements Runnable,KeyListener {
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
super.paintComponent(RabiClone.f.getBufferStrategy().getDrawGraphics());
// perform draws on pixels
render();
// ask ImageProducer to update image
mImageProducer.newPixels();
// 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();
}

Loading…
Cancel
Save