hud.tick(ticks);
}
}
private void render() {
BufferStrategy bs = getBufferStrategy();
if (bs == null) {
createBufferStrategy(3);
return;
}
Graphics g = bs.getDrawGraphics();
g.setColor(Color.BLACK);
g.fillRect(0, 0, getWidth(), getHeight());
if (gui != null) {
gui.render();
for (int y = 0; y < HEIGHT; y++) {
for (int x = 0; x < WIDTH; x++) {
int colorCode = gui.pixels[x + y * gui.width];
pixels[x + y * WIDTH] = colorCode + (0xFF << 24);
}
}
} else {
if (world != null) {
world.render(screen);
for (int y = 0; y < screen.height; y++) {
for (int x = 0; x < screen.width; x++) {
int colorCode = screen.pixels[x + y * screen.width];
if (colorCode < 255) {
pixels[x + y * WIDTH] = colors[colorCode];
}
}
}
if (hud != null) {
hud.pixels = pixels;
hud.render();
}
}
}
g.drawImage(image, 0, 0, getWidth(), getHeight(), null);
g.dispose();
bs.show();
}