Skip to content

Commit

Permalink
Changed image type to ARGB instead of RGB.
Browse files Browse the repository at this point in the history
The game now requests focus (No need to click on the window anymore for focus.)
  • Loading branch information
svenar-nl committed Aug 11, 2016
1 parent 9ba607c commit 49d8817
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Java/src/me/winspeednl/libz/screen/Window.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class Window {
private BufferStrategy bufferStrategy;

public Window(GameCore gc) {
image = new BufferedImage(gc.getWidth(), gc.getHeight(), BufferedImage.TYPE_INT_RGB);
image = new BufferedImage(gc.getWidth(), gc.getHeight(), BufferedImage.TYPE_INT_ARGB);

canvas = new Canvas();
Dimension size = new Dimension((int)(gc.getWidth() * gc.getScale()), (int)(gc.getHeight() * gc.getScale()));
Expand All @@ -38,10 +38,14 @@ public Window(GameCore gc) {
frame.setLocationRelativeTo(null);
frame.setResizable(false);
frame.setVisible(true);
frame.toFront();
frame.requestFocus();

canvas.createBufferStrategy(3);
bufferStrategy = canvas.getBufferStrategy();
graphics = bufferStrategy.getDrawGraphics();

canvas.requestFocus();
}

public void update() {
Expand All @@ -59,6 +63,10 @@ public void cleanup() {
public Canvas getCanvas() {
return canvas;
}

public JFrame getFrame() {
return frame;
}

public BufferedImage getImage() {
return image;
Expand Down

0 comments on commit 49d8817

Please sign in to comment.