Use buffer strategy with proper buffer rotation

Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com>
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
main
sigonasr2 3 years ago
parent dec88d32f5
commit e31c04c198
  1. BIN
      RabiClone_0.0a.zip
  2. BIN
      bin/RabiClone.jar
  3. 21
      src/sig/engine/Panel.java

Binary file not shown.

Binary file not shown.

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

Loading…
Cancel
Save