//loading image
void loadImages() {
bg = new ImageIcon(this.getClass().getResource("background.png")).getImage();
}
//drawing image
void draw(Graphics2D g2d) {
g2d.drawImage(bg, 0, 0, null);
}
//this one on init to create shit
void init()P
createBufferStrategy(2);
strategy = getBufferStrategy();
g2d = (Graphics2D) strategy.getDrawGraphics();
}
//this one has more code, bet important is this piece of code
private void graphics() {
strategy = getBufferStrategy();
g2d = (Graphics2D) strategy.getDrawGraphics();
strategy.show();
}
//and in game loop I draw it
private void gameLoop() {
while (running){
graphics();
draw(g2d);
g2d.dispose();
}
}
Show differencesHistory of post edits
#ActualPlutonium
Posted 29 April 2012 - 05:02 PM
Maybe it will help
#1Plutonium
Posted 29 April 2012 - 05:01 PM
Maybe it will help
//loading image
void loadImages() {
bg = new ImageIcon(this.getClass().getResource("background.png")).getImage();
}
//drawing image
void draw(Graphics2D g2d) {
g2d.drawImage(bg, 0, 0, null);
}
//this one on init to create shit
createBufferStrategy(2);
strategy = getBufferStrategy();
g2d = (Graphics2D) strategy.getDrawGraphics();
//this one has more code, bet important is this piece of code
private void graphics() {
strategy = getBufferStrategy();
g2d = (Graphics2D) strategy.getDrawGraphics();
strategy.show();
}
//and in game loop I draw it
private void gameLoop() {
while (running){
graphics();
draw(g2d);
g2d.dispose();
}
}