Fullscreen fix in FreeMove
This commit is contained in:
parent
250c3053cb
commit
4a18642f0c
@ -27,6 +27,7 @@ public class Game extends JFrame {
|
|||||||
|
|
||||||
//tohle spustí na začátku menu
|
//tohle spustí na začátku menu
|
||||||
add(menu);
|
add(menu);
|
||||||
|
menu.start();
|
||||||
|
|
||||||
//tohle spustí na začátku hru
|
//tohle spustí na začátku hru
|
||||||
// add(freeMove);
|
// add(freeMove);
|
||||||
@ -38,19 +39,10 @@ public class Game extends JFrame {
|
|||||||
setLocationRelativeTo(null);
|
setLocationRelativeTo(null);
|
||||||
setResizable(false);
|
setResizable(false);
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
setLayout(new BorderLayout());
|
|
||||||
getContentPane().setBackground(Color.BLACK);
|
getContentPane().setBackground(Color.BLACK);
|
||||||
setExtendedState(game().MAXIMIZED_BOTH);
|
setExtendedState(MAXIMIZED_BOTH);
|
||||||
centerContent();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public Game game() {return this;}
|
public Game game() {return this;}
|
||||||
|
|
||||||
public void centerContent() {
|
|
||||||
getContentPane().getComponent(0).setLocation((Toolkit.getDefaultToolkit().getScreenSize().width - (WINDOW_WIDTH * CELL_SIZE)) / 2, (Toolkit.getDefaultToolkit().getScreenSize().height - (WINDOW_HEIGHT * CELL_SIZE)) / 2);
|
|
||||||
getContentPane().getComponent(0).setSize(WINDOW_WIDTH * CELL_SIZE, WINDOW_HEIGHT * CELL_SIZE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -82,7 +82,6 @@ public class WindowOfFreeMove extends JLayeredPane {
|
|||||||
public Camera getCamera() { return camera; }
|
public Camera getCamera() { return camera; }
|
||||||
|
|
||||||
public WindowOfFreeMove(JFrame game) {
|
public WindowOfFreeMove(JFrame game) {
|
||||||
|
|
||||||
this.game = game;
|
this.game = game;
|
||||||
isReadyToPaint = false;
|
isReadyToPaint = false;
|
||||||
canPersonMove = true;
|
canPersonMove = true;
|
||||||
@ -145,7 +144,7 @@ public class WindowOfFreeMove extends JLayeredPane {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void start(boolean newGame) {
|
public void start(boolean newGame) {
|
||||||
|
centerContent();
|
||||||
mapLinkedList = new LinkedList<>();
|
mapLinkedList = new LinkedList<>();
|
||||||
mapManager = new MapManager(mapLinkedList, canvas, this);
|
mapManager = new MapManager(mapLinkedList, canvas, this);
|
||||||
|
|
||||||
@ -164,10 +163,8 @@ public class WindowOfFreeMove extends JLayeredPane {
|
|||||||
int startX = 4;
|
int startX = 4;
|
||||||
int startY = 2;
|
int startY = 2;
|
||||||
|
|
||||||
camera.moveCamera();
|
|
||||||
mapManager.createMap();
|
mapManager.createMap();
|
||||||
isReadyToPaint = true;
|
isReadyToPaint = true;
|
||||||
canvas.repaint();
|
|
||||||
|
|
||||||
Npc npc2 = new Npc(startX, startY, boss, mapManager);
|
Npc npc2 = new Npc(startX, startY, boss, mapManager);
|
||||||
boss.setNpcs(npc2);
|
boss.setNpcs(npc2);
|
||||||
@ -175,11 +172,6 @@ public class WindowOfFreeMove extends JLayeredPane {
|
|||||||
musicManager = new MusicManager("Town1.wav");
|
musicManager = new MusicManager("Town1.wav");
|
||||||
// musicManager.playMusic();
|
// musicManager.playMusic();
|
||||||
|
|
||||||
Timer center = new Timer(1, actionEvent -> {
|
|
||||||
centerContent();
|
|
||||||
});
|
|
||||||
center.start();
|
|
||||||
|
|
||||||
Timer timer = new Timer(10, actionEvent -> {
|
Timer timer = new Timer(10, actionEvent -> {
|
||||||
mapManager.getActualMap().getPerson().move();
|
mapManager.getActualMap().getPerson().move();
|
||||||
camera.moveCamera();
|
camera.moveCamera();
|
||||||
@ -241,7 +233,7 @@ public class WindowOfFreeMove extends JLayeredPane {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void centerContent() {
|
public void centerContent() {
|
||||||
game.getContentPane().getComponent(0).setLocation((Toolkit.getDefaultToolkit().getScreenSize().width - (WINDOW_WIDTH * CELL_SIZE)) / 2, (Toolkit.getDefaultToolkit().getScreenSize().height - (WINDOW_HEIGHT * CELL_SIZE)) / 2);
|
game.getComponents()[0].setLocation((Toolkit.getDefaultToolkit().getScreenSize().width - (WINDOW_WIDTH * CELL_SIZE)) / 2, (Toolkit.getDefaultToolkit().getScreenSize().height - (WINDOW_HEIGHT * CELL_SIZE)) / 2);
|
||||||
game.getContentPane().getComponent(0).setSize(WINDOW_WIDTH * CELL_SIZE, WINDOW_HEIGHT * CELL_SIZE);
|
game.getComponents()[0].setSize(WINDOW_WIDTH * CELL_SIZE, WINDOW_HEIGHT * CELL_SIZE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4,6 +4,7 @@ import javax.swing.*;
|
|||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.sql.Time;
|
||||||
|
|
||||||
public class WindowOfMenu extends JLayeredPane {
|
public class WindowOfMenu extends JLayeredPane {
|
||||||
public static final int WINDOW_WIDTH = 13;
|
public static final int WINDOW_WIDTH = 13;
|
||||||
@ -53,6 +54,18 @@ public class WindowOfMenu extends JLayeredPane {
|
|||||||
add(startNewGame);
|
add(startNewGame);
|
||||||
add(loadSavedGame);
|
add(loadSavedGame);
|
||||||
add(exitGame);
|
add(exitGame);
|
||||||
|
setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void start(){
|
||||||
|
Timer timer = new Timer( 0, actionEvent -> {
|
||||||
|
setVisible(false);
|
||||||
|
centerContent();
|
||||||
|
this.repaint();
|
||||||
|
setVisible(true);
|
||||||
|
});
|
||||||
|
timer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cleanUp() {
|
private void cleanUp() {
|
||||||
@ -71,4 +84,9 @@ public class WindowOfMenu extends JLayeredPane {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public WindowOfMenu menu() { return this; }
|
public WindowOfMenu menu() { return this; }
|
||||||
|
|
||||||
|
public void centerContent() {
|
||||||
|
game.getComponents()[0].setLocation((Toolkit.getDefaultToolkit().getScreenSize().width - (WINDOW_WIDTH * CELL_SIZE)) / 2, (Toolkit.getDefaultToolkit().getScreenSize().height - (WINDOW_HEIGHT * CELL_SIZE)) / 2);
|
||||||
|
game.getComponents()[0].setSize(WINDOW_WIDTH * CELL_SIZE, WINDOW_HEIGHT * CELL_SIZE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<location>
|
<location>
|
||||||
<map>m1</map>
|
<map>m1</map>
|
||||||
<x>8</x>
|
<x>1</x>
|
||||||
<y>4</y>
|
<y>7</y>
|
||||||
</location>
|
</location>
|
||||||
Loading…
x
Reference in New Issue
Block a user