From 93faa22b9bd0814c62328204431fcb0082835437 Mon Sep 17 00:00:00 2001 From: iryupnik Date: Thu, 16 Apr 2020 16:19:35 +0200 Subject: [PATCH] Starting of creating battle module --- .../ruscz/game/gameOfProd/Battle/Battle.java | 4 + .../game/gameOfProd/Battle/BattlePerson.java | 4 + .../ruscz/game/gameOfProd/Battle/Enemy.java | 4 + .../ruscz/game/gameOfProd/Battle/Hero.java | 4 + .../gameOfProd/Cells/RandomEncounterCell.java | 17 ++++ .../ruscz/game/gameOfProd/Dialog/MenuBar.java | 6 ++ .../{ => ruscz/game/gameOfProd}/Game.java | 26 ++++-- .../gameOfProd/Windows/WindowOfBattle.java | 23 +++++ .../game/gameOfProd/Windows/WindowOfMenu.java | 10 ++- src/main/resources/META-INF/MANIFEST.MF | 3 + src/main/resources/dialogs/ohhimark.txt | 2 +- src/main/resources/save/savedGame/events.txt | 90 ------------------- src/main/resources/save/savedGame/person.txt | 6 -- src/main/resources/save/savedGame/village.txt | 1 - 14 files changed, 90 insertions(+), 110 deletions(-) create mode 100644 src/main/java/ruscz/game/gameOfProd/Battle/Battle.java create mode 100644 src/main/java/ruscz/game/gameOfProd/Battle/BattlePerson.java create mode 100644 src/main/java/ruscz/game/gameOfProd/Battle/Enemy.java create mode 100644 src/main/java/ruscz/game/gameOfProd/Battle/Hero.java create mode 100644 src/main/java/ruscz/game/gameOfProd/Cells/RandomEncounterCell.java create mode 100644 src/main/java/ruscz/game/gameOfProd/Dialog/MenuBar.java rename src/main/java/{ => ruscz/game/gameOfProd}/Game.java (66%) create mode 100644 src/main/java/ruscz/game/gameOfProd/Windows/WindowOfBattle.java create mode 100644 src/main/resources/META-INF/MANIFEST.MF diff --git a/src/main/java/ruscz/game/gameOfProd/Battle/Battle.java b/src/main/java/ruscz/game/gameOfProd/Battle/Battle.java new file mode 100644 index 0000000..c596a33 --- /dev/null +++ b/src/main/java/ruscz/game/gameOfProd/Battle/Battle.java @@ -0,0 +1,4 @@ +package ruscz.game.gameOfProd.Battle; + +public class Battle { +} diff --git a/src/main/java/ruscz/game/gameOfProd/Battle/BattlePerson.java b/src/main/java/ruscz/game/gameOfProd/Battle/BattlePerson.java new file mode 100644 index 0000000..b5de7fa --- /dev/null +++ b/src/main/java/ruscz/game/gameOfProd/Battle/BattlePerson.java @@ -0,0 +1,4 @@ +package ruscz.game.gameOfProd.Battle; + +public class BattlePerson { +} diff --git a/src/main/java/ruscz/game/gameOfProd/Battle/Enemy.java b/src/main/java/ruscz/game/gameOfProd/Battle/Enemy.java new file mode 100644 index 0000000..4f3895f --- /dev/null +++ b/src/main/java/ruscz/game/gameOfProd/Battle/Enemy.java @@ -0,0 +1,4 @@ +package ruscz.game.gameOfProd.Battle; + +public class Enemy extends BattlePerson { +} diff --git a/src/main/java/ruscz/game/gameOfProd/Battle/Hero.java b/src/main/java/ruscz/game/gameOfProd/Battle/Hero.java new file mode 100644 index 0000000..5a295e4 --- /dev/null +++ b/src/main/java/ruscz/game/gameOfProd/Battle/Hero.java @@ -0,0 +1,4 @@ +package ruscz.game.gameOfProd.Battle; + +public class Hero extends BattlePerson { +} diff --git a/src/main/java/ruscz/game/gameOfProd/Cells/RandomEncounterCell.java b/src/main/java/ruscz/game/gameOfProd/Cells/RandomEncounterCell.java new file mode 100644 index 0000000..4d143bb --- /dev/null +++ b/src/main/java/ruscz/game/gameOfProd/Cells/RandomEncounterCell.java @@ -0,0 +1,17 @@ +package ruscz.game.gameOfProd.Cells; + +import ruscz.game.gameOfProd.Game; +import ruscz.game.gameOfProd.Windows.WindowOfFreeMove; + +import java.awt.*; + +public class RandomEncounterCell extends Cell { + private final int level; + private final Game game; + + public RandomEncounterCell(int x, int y, int lvl, Game game) { + super(x, y, WindowOfFreeMove.CELL_SIZE, Color.pink); + this.level = lvl; + this.game = game; + } +} diff --git a/src/main/java/ruscz/game/gameOfProd/Dialog/MenuBar.java b/src/main/java/ruscz/game/gameOfProd/Dialog/MenuBar.java new file mode 100644 index 0000000..be4f7b5 --- /dev/null +++ b/src/main/java/ruscz/game/gameOfProd/Dialog/MenuBar.java @@ -0,0 +1,6 @@ +package ruscz.game.gameOfProd.Dialog; + +import javax.swing.*; + +public class MenuBar extends JPanel { +} diff --git a/src/main/java/Game.java b/src/main/java/ruscz/game/gameOfProd/Game.java similarity index 66% rename from src/main/java/Game.java rename to src/main/java/ruscz/game/gameOfProd/Game.java index eec15b2..7860b89 100644 --- a/src/main/java/Game.java +++ b/src/main/java/ruscz/game/gameOfProd/Game.java @@ -1,13 +1,11 @@ +package ruscz.game.gameOfProd; + +import ruscz.game.gameOfProd.Windows.WindowOfBattle; import ruscz.game.gameOfProd.Windows.WindowOfFreeMove; import ruscz.game.gameOfProd.Windows.WindowOfMenu; import javax.swing.*; import java.awt.*; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.awt.event.WindowEvent; -import java.awt.image.BufferedImage; public class Game extends JFrame { private static final int WINDOW_WIDTH = 13; @@ -16,6 +14,19 @@ public class Game extends JFrame { private WindowOfMenu menu; private WindowOfFreeMove freeMove; + private WindowOfBattle battle; + + public WindowOfMenu getMenu() { + return menu; + } + + public WindowOfFreeMove getFreeMove() { + return freeMove; + } + + public WindowOfBattle getBattle() { + return battle; + } public static void main(String[] args) { new Game(); @@ -23,7 +34,8 @@ public class Game extends JFrame { public Game() { freeMove = new WindowOfFreeMove(this); - menu = new WindowOfMenu(this, freeMove); + menu = new WindowOfMenu(this); + battle = new WindowOfBattle(this); //tohle spustí na začátku menu add(menu); @@ -40,8 +52,6 @@ public class Game extends JFrame { setVisible(true); getContentPane().setBackground(Color.BLACK); setExtendedState(MAXIMIZED_BOTH); - 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); } public Game game() {return this;} diff --git a/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfBattle.java b/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfBattle.java new file mode 100644 index 0000000..f809d3f --- /dev/null +++ b/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfBattle.java @@ -0,0 +1,23 @@ +package ruscz.game.gameOfProd.Windows; + +import ruscz.game.gameOfProd.Game; + +import javax.swing.*; +import java.awt.*; + + +public class WindowOfBattle { + private Canvas canvas; + + public WindowOfBattle(Game game) { + canvas = new Canvas(); + + } + + class Canvas extends JPanel { + @Override + public void paint(Graphics g) { + + } + } +} diff --git a/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfMenu.java b/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfMenu.java index d93f601..9040cdb 100644 --- a/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfMenu.java +++ b/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfMenu.java @@ -1,25 +1,26 @@ package ruscz.game.gameOfProd.Windows; +import ruscz.game.gameOfProd.Game; + import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.awt.image.BufferedImage; -import java.sql.Time; public class WindowOfMenu extends JLayeredPane { public static final int WINDOW_WIDTH = 13; public static final int WINDOW_HEIGHT = 13; public static final int CELL_SIZE = 50; - private JFrame game; + private Game game; private WindowOfFreeMove freeMove; private JButton startNewGame; private JButton loadSavedGame; private JButton exitGame; - public WindowOfMenu(JFrame game, WindowOfFreeMove freeMove) { + public WindowOfMenu(Game game) { this.game = game; - this.freeMove = freeMove; + this.freeMove = game.getFreeMove(); startNewGame = new JButton("START NEW GAME"); //startNewGame.setFocusable(false); @@ -49,6 +50,7 @@ public class WindowOfMenu extends JLayeredPane { add(loadSavedGame); add(exitGame); } + private void cleanUp() { setVisible(false); startNewGame.removeActionListener(startNewGame.getActionListeners()[0]); diff --git a/src/main/resources/META-INF/MANIFEST.MF b/src/main/resources/META-INF/MANIFEST.MF new file mode 100644 index 0000000..4651c3a --- /dev/null +++ b/src/main/resources/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Main-Class: ruscz.game.gameOfProd.Game + diff --git a/src/main/resources/dialogs/ohhimark.txt b/src/main/resources/dialogs/ohhimark.txt index c6ad33f..e19a5db 100644 --- a/src/main/resources/dialogs/ohhimark.txt +++ b/src/main/resources/dialogs/ohhimark.txt @@ -2,7 +2,7 @@ boss-face.png Oh, hi Mark. -I know, this is on very short notice
but as you've probably heard,
we kinda need someone on the Game of Prod. +I know, this is on very short notice
but as you've probably heard,
we kinda need someone on the ruscz.game.gameOfProd.Game of Prod. And that someone is gonna be,
you guessed it, you. You start by tomorrow. You can go now. Bye. diff --git a/src/main/resources/save/savedGame/events.txt b/src/main/resources/save/savedGame/events.txt index 0dd4360..e69de29 100644 --- a/src/main/resources/save/savedGame/events.txt +++ b/src/main/resources/save/savedGame/events.txt @@ -1,90 +0,0 @@ - - m1 - - - - - m2 - - - 7 - 2 - true - - - - - m3 - - - 2 - 5 - true - - - - - m4 - - - 3 - 3 - true - - - - - m6 - - - 11 - 11 - true - - - - - tutorial - - - - - openspace - - - 7 - 4 - true - - - 15 - 7 - true - - - - - office - - - 1 - 9 - true - - - - - boss - - - 4 - 18 - true - - - - - treasure - - - diff --git a/src/main/resources/save/savedGame/person.txt b/src/main/resources/save/savedGame/person.txt index a9fc868..e69de29 100644 --- a/src/main/resources/save/savedGame/person.txt +++ b/src/main/resources/save/savedGame/person.txt @@ -1,6 +0,0 @@ - - boss - 4 - 18 - 2 - \ No newline at end of file diff --git a/src/main/resources/save/savedGame/village.txt b/src/main/resources/save/savedGame/village.txt index 1b4bc7b..e69de29 100644 --- a/src/main/resources/save/savedGame/village.txt +++ b/src/main/resources/save/savedGame/village.txt @@ -1 +0,0 @@ -TODO: Village \ No newline at end of file