This commit is contained in:
iryupnik 2020-04-06 14:32:16 +02:00
parent 00c34e649d
commit 99f9e80246
7 changed files with 68 additions and 10 deletions

View File

@ -4,11 +4,12 @@ import ruscz.game.gameOfProd.Windows.WindowOfMenu;
import javax.swing.*; import javax.swing.*;
import java.awt.event.KeyAdapter; import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
public class Game extends JFrame { public class Game extends JFrame {
public static final int WINDOW_WIDTH = 11; private static final int WINDOW_WIDTH = 11;
public static final int WINDOW_HEIGHT = 11; private static final int WINDOW_HEIGHT = 11;
public static final int CELL_SIZE = 50; public static final int CELL_SIZE = 50;
private static final int KEY_FULLSCREEN = 115; private static final int KEY_FULLSCREEN = 115;
@ -26,11 +27,11 @@ public class Game extends JFrame {
menu = new WindowOfMenu(this, freeMove); menu = new WindowOfMenu(this, freeMove);
//tohle spustí na začátku menu, ale nejsem schopen přinutit to menu, aby se vzdalo Listeneru a mohl ho využít Game //tohle spustí na začátku menu, ale nejsem schopen přinutit to menu, aby se vzdalo Listeneru a mohl ho využít Game
//add(menu); add(menu);
//tohle spustí na začátku hru, vše funguje tak, jak má //tohle spustí na začátku hru, vše funguje tak, jak má
add(freeMove); // add(freeMove);
freeMove.start(true); // freeMove.start(true);
setDefaultCloseOperation(EXIT_ON_CLOSE); setDefaultCloseOperation(EXIT_ON_CLOSE);
setUndecorated(true); setUndecorated(true);
@ -53,7 +54,6 @@ public class Game extends JFrame {
setExtendedState(NORMAL); setExtendedState(NORMAL);
else else
setExtendedState(MAXIMIZED_BOTH); setExtendedState(MAXIMIZED_BOTH);
return;
} }
else { else {

View File

@ -120,7 +120,6 @@ public class WindowOfFreeMove extends JLayeredPane {
} }
public void start(boolean newGame) { public void start(boolean newGame) {
mapLinkedList = new LinkedList<>(); mapLinkedList = new LinkedList<>();
mapManager = new MapManager(mapLinkedList, canvas, this); mapManager = new MapManager(mapLinkedList, canvas, this);

View File

@ -26,6 +26,7 @@ public class WindowOfMenu extends JLayeredPane {
background.setBackground(Color.BLACK); background.setBackground(Color.BLACK);
startNewGame = new JButton("START NEW GAME"); startNewGame = new JButton("START NEW GAME");
startNewGame.setFocusable(false);
startNewGame.setBounds((WINDOW_WIDTH*CELL_SIZE - 200) / 2,(WINDOW_HEIGHT*CELL_SIZE - 30) / 2 -70,200,30); startNewGame.setBounds((WINDOW_WIDTH*CELL_SIZE - 200) / 2,(WINDOW_HEIGHT*CELL_SIZE - 30) / 2 -70,200,30);
startNewGame.setActionCommand("startNewGame"); startNewGame.setActionCommand("startNewGame");
startNewGame.addActionListener(new ActionListener() { startNewGame.addActionListener(new ActionListener() {
@ -33,11 +34,13 @@ public class WindowOfMenu extends JLayeredPane {
public void actionPerformed(ActionEvent actionEvent) { public void actionPerformed(ActionEvent actionEvent) {
cleanUp(); cleanUp();
game.add(freeMove); game.add(freeMove);
freeMove.setFocusable(true);
freeMove.start(true); freeMove.start(true);
} }
}); });
loadSavedGame = new JButton("LOAD SAVED GAME"); loadSavedGame = new JButton("LOAD SAVED GAME");
loadSavedGame.setFocusable(false);
loadSavedGame.setBounds((WINDOW_WIDTH*CELL_SIZE - 200) / 2,(WINDOW_HEIGHT*CELL_SIZE - 30) / 2,200,30); loadSavedGame.setBounds((WINDOW_WIDTH*CELL_SIZE - 200) / 2,(WINDOW_HEIGHT*CELL_SIZE - 30) / 2,200,30);
loadSavedGame.setActionCommand("loadSavedGame"); loadSavedGame.setActionCommand("loadSavedGame");
loadSavedGame.addActionListener(new ActionListener() { loadSavedGame.addActionListener(new ActionListener() {
@ -45,11 +48,13 @@ public class WindowOfMenu extends JLayeredPane {
public void actionPerformed(ActionEvent actionEvent) { public void actionPerformed(ActionEvent actionEvent) {
cleanUp(); cleanUp();
game.add(freeMove); game.add(freeMove);
freeMove.setFocusable(true);
freeMove.start(false); freeMove.start(false);
} }
}); });
exitGame = new JButton("EXIT GAME"); exitGame = new JButton("EXIT GAME");
exitGame.setFocusable(false);
exitGame.setBounds((WINDOW_WIDTH*CELL_SIZE - 200) / 2,(WINDOW_HEIGHT*CELL_SIZE - 30) / 2 + 70,200,30); exitGame.setBounds((WINDOW_WIDTH*CELL_SIZE - 200) / 2,(WINDOW_HEIGHT*CELL_SIZE - 30) / 2 + 70,200,30);
exitGame.setActionCommand("exitGame"); exitGame.setActionCommand("exitGame");
exitGame.addActionListener(new ActionListener() { exitGame.addActionListener(new ActionListener() {
@ -68,9 +73,6 @@ public class WindowOfMenu extends JLayeredPane {
private void cleanUp() { private void cleanUp() {
setVisible(false); setVisible(false);
game.remove(this); game.remove(this);
// startNewGame.removeAll();
// loadSavedGame.removeAll();
// exitGame.removeAll();
} }
public WindowOfMenu menu() { return this; } public WindowOfMenu menu() { return this; }

View File

@ -0,0 +1,50 @@
<map>
<mapName>m1</mapName>
<events>
</events>
</map>
<map>
<mapName>m2</mapName>
<events>
<event>
<x>7</x>
<y>2</y>
<active>true</active>
</event>
</events>
</map>
<map>
<mapName>m3</mapName>
<events>
<event>
<x>2</x>
<y>5</y>
<active>true</active>
</event>
</events>
</map>
<map>
<mapName>m4</mapName>
<events>
<event>
<x>3</x>
<y>3</y>
<active>true</active>
</event>
</events>
</map>
<map>
<mapName>m5</mapName>
<events>
</events>
</map>
<map>
<mapName>m6</mapName>
<events>
<event>
<x>11</x>
<y>11</y>
<active>true</active>
</event>
</events>
</map>

View File

@ -0,0 +1 @@
TODO: Inventory

View File

@ -0,0 +1,5 @@
<location>
<map>m6</map>
<x>11</x>
<y>1</y>
</location>

View File

@ -0,0 +1 @@
TODO: Village