Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/main/java/fri/shapesge/engine/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,8 @@ public void deregisterEventTarget(Object target) {
public GameSoundSystem getGameSoundSystem() {
return this.gameSoundSystem;
}

public void adjustFullscreenScaling(int width, int height) {
this.gameWindow.resizeFullscreenScaling(width, height);
}
}
20 changes: 18 additions & 2 deletions src/main/java/fri/shapesge/engine/GameWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class GameWindow {
private final GameObjects gameObjects;
private final GameInputProcessor gameInputProcessor;
private final GameFPSCounter fpsCounter;
private final int width;
private final int height;
private int width;
private int height;
private final GameEventDispatcher gameEventDispatcher;
private final Color backgroundColor;
private final boolean showInfo;
Expand Down Expand Up @@ -122,6 +122,22 @@ public void showIfNeeded() {
}
}

public void resizeFullscreenScaling(int width, int height) {
if (this.isFullscreen) {
DEVICE.setFullScreenWindow(null);

this.width = width;
this.height = height;

Dimension dimension = new Dimension(width, height);
this.frame.setSize(dimension);
this.gamePanel.setPreferredSize(dimension);

DEVICE.setFullScreenWindow(this.frame);
this.gamePanel.resized();
}
}

private class GamePanel extends Canvas {
private AffineTransform canvasTransform;
private AffineTransform invertedCanvasTransform;
Expand Down