anonymous / DB.java
Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

More sophisticated double-buffered rendering

View DB.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
private VolatileImage drawImage = null;
private int drawImageWidth = 800;
private int drawImageHeight = 600;
 
public void render(BufferStrategy strategy) {
if (drawImage == null) {
drawImage = createVolatileImage(drawImageWidth, drawImageHeight);
}
Graphics2D drawGraphics = (Graphics2D) drawImage.getGraphics();
// TODO: use `drawGraphics` to draw game graphics (background, platforms, player, etc.)
 
// render a single frame:
do {
do {
Graphics2D renderGraphics = (Graphics2D) strategy.getDrawGraphics();
renderGraphics.drawImage(drawImage, 0, 0, null);
renderGraphics.dispose();
} while (strategy.contentsRestored());
strategy.show();
} while (strategy.contentsLost());
Toolkit.getDefaultToolkit().sync();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.