diff --git a/src/main/java/Game.java b/src/main/java/Game.java index 7f796a7..0ad8cf4 100644 --- a/src/main/java/Game.java +++ b/src/main/java/Game.java @@ -1,3 +1,6 @@ +import ruscz.game.gameOfProd.Map.MapManager; +import ruscz.game.gameOfProd.Windows.WindowOfFreeMove; + public class Game { private MapManager mm; diff --git a/src/main/java/MapManager.java b/src/main/java/MapManager.java deleted file mode 100644 index a477aba..0000000 --- a/src/main/java/MapManager.java +++ /dev/null @@ -1,14 +0,0 @@ -import java.util.LinkedList; - -public class MapManager { - WindowOfFreeMove window; - LinkedList maps; - Map actualMap; - - MapManager(WindowOfFreeMove window){ - this.window = window; - } - - - -} diff --git a/src/main/java/Block.java b/src/main/java/ruscz/game/gameOfProd/Cells/Block.java similarity index 86% rename from src/main/java/Block.java rename to src/main/java/ruscz/game/gameOfProd/Cells/Block.java index 310b36a..ff3ccaa 100644 --- a/src/main/java/Block.java +++ b/src/main/java/ruscz/game/gameOfProd/Cells/Block.java @@ -1,3 +1,8 @@ +package ruscz.game.gameOfProd.Cells; + +import ruscz.game.gameOfProd.Image.ImageCell; +import ruscz.game.gameOfProd.Windows.WindowOfFreeMove; + import java.awt.*; public class Block extends Cell { diff --git a/src/main/java/Cell.java b/src/main/java/ruscz/game/gameOfProd/Cells/Cell.java similarity index 94% rename from src/main/java/Cell.java rename to src/main/java/ruscz/game/gameOfProd/Cells/Cell.java index adea154..83adbee 100644 --- a/src/main/java/Cell.java +++ b/src/main/java/ruscz/game/gameOfProd/Cells/Cell.java @@ -1,3 +1,5 @@ +package ruscz.game.gameOfProd.Cells; + import java.awt.*; public class Cell { diff --git a/src/main/java/EventMoveToCell.java b/src/main/java/ruscz/game/gameOfProd/Cells/EventMoveToCell.java similarity index 77% rename from src/main/java/EventMoveToCell.java rename to src/main/java/ruscz/game/gameOfProd/Cells/EventMoveToCell.java index 752b1a3..3896fc9 100644 --- a/src/main/java/EventMoveToCell.java +++ b/src/main/java/ruscz/game/gameOfProd/Cells/EventMoveToCell.java @@ -1,3 +1,9 @@ +package ruscz.game.gameOfProd.Cells; + +import ruscz.game.gameOfProd.Cells.Cell; +import ruscz.game.gameOfProd.Map.Map; +import ruscz.game.gameOfProd.Windows.WindowOfFreeMove; + import java.awt.*; public class EventMoveToCell extends Cell { @@ -18,14 +24,14 @@ public class EventMoveToCell extends Cell { } public EventMoveToCell(int id, int directionOut, int x, int y, String nameOfMap){ - super(x,y,WindowOfFreeMove.CELL_SIZE, Color.green); + super(x,y, WindowOfFreeMove.CELL_SIZE, Color.green); this.id = id; this.directionOut = directionOut; this.map = Map.findMapByName(nameOfMap); } public EventMoveToCell(int id, int directionOut, int x, int y, Map map, WindowOfFreeMove window){ - super(x,y,WindowOfFreeMove.CELL_SIZE, Color.green); + super(x,y, WindowOfFreeMove.CELL_SIZE, Color.green); this.id = id; this.directionOut = directionOut; this.map = map; @@ -35,7 +41,7 @@ public class EventMoveToCell extends Cell { public int getDirectionOut() { return directionOut; } public void moveToMap() { - window.getMap().getPerson().stopPerson(); + //window.getMap().getPerson().stopPerson(); window.getMap().setIdExit(id); window.setMap(this.map); window.getMap().setIdExit(id); @@ -49,6 +55,6 @@ public class EventMoveToCell extends Cell { super.paint(g); g.drawImage(window.getMap().getImageCell().getImagesOfTiles().get(277), getX() * WindowOfFreeMove.CELL_SIZE, getY() * WindowOfFreeMove.CELL_SIZE, WindowOfFreeMove.CELL_SIZE, WindowOfFreeMove.CELL_SIZE, null); - g.drawString(Integer.toString(getId()), getX()*WindowOfFreeMove.CELL_SIZE, getY()*WindowOfFreeMove.CELL_SIZE); + g.drawString(Integer.toString(getId()), getX()* WindowOfFreeMove.CELL_SIZE, getY()* WindowOfFreeMove.CELL_SIZE); } } diff --git a/src/main/java/InteractionCell.java b/src/main/java/ruscz/game/gameOfProd/Cells/InteractionCell.java similarity index 83% rename from src/main/java/InteractionCell.java rename to src/main/java/ruscz/game/gameOfProd/Cells/InteractionCell.java index 440b823..36a1a36 100644 --- a/src/main/java/InteractionCell.java +++ b/src/main/java/ruscz/game/gameOfProd/Cells/InteractionCell.java @@ -1,3 +1,11 @@ +package ruscz.game.gameOfProd.Cells; + +import ruscz.game.gameOfProd.Cells.Cell; +import ruscz.game.gameOfProd.Dialog.Dialog; +import ruscz.game.gameOfProd.Image.ImageCell; +import ruscz.game.gameOfProd.Image.ImageDialog; +import ruscz.game.gameOfProd.Windows.WindowOfFreeMove; + import java.awt.*; import java.io.File; import java.io.FileNotFoundException; @@ -5,11 +13,11 @@ import java.util.Scanner; public class InteractionCell extends Cell { private String message; - private Dialog dialog; + private ruscz.game.gameOfProd.Dialog.Dialog dialog; private Scanner scanner; private ImageCell imageCell; - InteractionCell(int x, int y, String message, Dialog dialog, ImageCell imageCell) { + public InteractionCell(int x, int y, String message, Dialog dialog, ImageCell imageCell) { super(x, y, WindowOfFreeMove.CELL_SIZE, Color.ORANGE); this.message = message; this.dialog = dialog; diff --git a/src/main/java/Person.java b/src/main/java/ruscz/game/gameOfProd/Cells/Person.java similarity index 97% rename from src/main/java/Person.java rename to src/main/java/ruscz/game/gameOfProd/Cells/Person.java index e6ca2ea..a8c64aa 100644 --- a/src/main/java/Person.java +++ b/src/main/java/ruscz/game/gameOfProd/Cells/Person.java @@ -1,4 +1,9 @@ -import javax.swing.*; +package ruscz.game.gameOfProd.Cells; + +import ruscz.game.gameOfProd.Image.ImagePerson; +import ruscz.game.gameOfProd.Map.Map; +import ruscz.game.gameOfProd.Windows.WindowOfFreeMove; + import java.awt.*; public class Person extends Cell { diff --git a/src/main/java/TypeOfCell.java b/src/main/java/ruscz/game/gameOfProd/Cells/TypeOfCell.java similarity index 65% rename from src/main/java/TypeOfCell.java rename to src/main/java/ruscz/game/gameOfProd/Cells/TypeOfCell.java index c621655..b4c3774 100644 --- a/src/main/java/TypeOfCell.java +++ b/src/main/java/ruscz/game/gameOfProd/Cells/TypeOfCell.java @@ -1,3 +1,5 @@ +package ruscz.game.gameOfProd.Cells; + public enum TypeOfCell { BLOCK, EMPTY, MOVETO, EVENT, SPAWNPOINT; } diff --git a/src/main/java/Dialog.java b/src/main/java/ruscz/game/gameOfProd/Dialog/Dialog.java similarity index 95% rename from src/main/java/Dialog.java rename to src/main/java/ruscz/game/gameOfProd/Dialog/Dialog.java index 87670a5..98c6f3c 100644 --- a/src/main/java/Dialog.java +++ b/src/main/java/ruscz/game/gameOfProd/Dialog/Dialog.java @@ -1,3 +1,7 @@ +package ruscz.game.gameOfProd.Dialog; + +import ruscz.game.gameOfProd.Image.ImageDialog; + import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; @@ -27,7 +31,7 @@ public class Dialog { charNumber = 0; } - Dialog(DialogBar dialogBar) { + public Dialog(DialogBar dialogBar) { this.dialogBar = dialogBar; charNumber = 0; } diff --git a/src/main/java/DialogBar.java b/src/main/java/ruscz/game/gameOfProd/Dialog/DialogBar.java similarity index 84% rename from src/main/java/DialogBar.java rename to src/main/java/ruscz/game/gameOfProd/Dialog/DialogBar.java index 36facd3..d815409 100644 --- a/src/main/java/DialogBar.java +++ b/src/main/java/ruscz/game/gameOfProd/Dialog/DialogBar.java @@ -1,3 +1,7 @@ +package ruscz.game.gameOfProd.Dialog; + +import ruscz.game.gameOfProd.Image.ImageDialog; + import javax.swing.*; import java.awt.*; diff --git a/src/main/java/ImageCell.java b/src/main/java/ruscz/game/gameOfProd/Image/ImageCell.java similarity index 94% rename from src/main/java/ImageCell.java rename to src/main/java/ruscz/game/gameOfProd/Image/ImageCell.java index c5b652f..34bc0ad 100644 --- a/src/main/java/ImageCell.java +++ b/src/main/java/ruscz/game/gameOfProd/Image/ImageCell.java @@ -1,3 +1,7 @@ +package ruscz.game.gameOfProd.Image; + +import ruscz.game.gameOfProd.Windows.WindowOfFreeMove; + import javax.imageio.ImageIO; import javax.print.DocFlavor; import java.awt.*; @@ -42,7 +46,7 @@ public class ImageCell { private void ImageTileset(String[] mapInfo) { try { - image = ImageIO.read(getClass().getResource(mapInfo[1])); + image = ImageIO.read(new File("src/main/resources/" + mapInfo[1])); } catch (IOException e) { e.printStackTrace(); } diff --git a/src/main/java/ImageDialog.java b/src/main/java/ruscz/game/gameOfProd/Image/ImageDialog.java similarity index 86% rename from src/main/java/ImageDialog.java rename to src/main/java/ruscz/game/gameOfProd/Image/ImageDialog.java index 396043f..52a6f2b 100644 --- a/src/main/java/ImageDialog.java +++ b/src/main/java/ruscz/game/gameOfProd/Image/ImageDialog.java @@ -1,3 +1,5 @@ +package ruscz.game.gameOfProd.Image; + import javax.imageio.ImageIO; import java.awt.*; import java.io.IOException; @@ -10,7 +12,7 @@ public class ImageDialog { return image; } - ImageDialog(String name){ + public ImageDialog(String name){ this.name = name; parseImage(); } diff --git a/src/main/java/ImagePerson.java b/src/main/java/ruscz/game/gameOfProd/Image/ImagePerson.java similarity index 87% rename from src/main/java/ImagePerson.java rename to src/main/java/ruscz/game/gameOfProd/Image/ImagePerson.java index 21e243d..258daac 100644 --- a/src/main/java/ImagePerson.java +++ b/src/main/java/ruscz/game/gameOfProd/Image/ImagePerson.java @@ -1,7 +1,10 @@ +package ruscz.game.gameOfProd.Image; + import javax.imageio.ImageIO; import javax.swing.*; import java.awt.*; import java.awt.image.*; +import java.io.File; import java.io.IOException; public class ImagePerson { @@ -21,7 +24,7 @@ public class ImagePerson { public ImagePerson(String name, Rectangle[] rectangles) { try { - image = ImageIO.read(getClass().getResource(name)); + image = ImageIO.read(new File("src/main/resources/" + name)); } catch (IOException e) { e.printStackTrace(); } diff --git a/src/main/java/Map.java b/src/main/java/ruscz/game/gameOfProd/Map/Map.java similarity index 91% rename from src/main/java/Map.java rename to src/main/java/ruscz/game/gameOfProd/Map/Map.java index ad13b20..c290674 100644 --- a/src/main/java/Map.java +++ b/src/main/java/ruscz/game/gameOfProd/Map/Map.java @@ -1,11 +1,10 @@ -import javax.imageio.ImageIO; -import java.awt.*; -import java.awt.image.BufferedImage; -import java.io.FileNotFoundException; -import java.io.IOException; +package ruscz.game.gameOfProd.Map; + +import ruscz.game.gameOfProd.Cells.*; +import ruscz.game.gameOfProd.Image.ImageCell; +import ruscz.game.gameOfProd.Windows.WindowOfFreeMove; + import java.util.LinkedList; -import java.io.File; -import java.util.Scanner; public class Map { private String name; @@ -46,7 +45,7 @@ public class Map { person = new Person(this); } - Map(int height, int width, Boolean isBlocked) { + public Map(int height, int width, Boolean isBlocked) { name = "Spawn"; idExit = 0; moveToCells = new LinkedList(); @@ -183,7 +182,7 @@ public class Map { } } - boolean isBusyCell(int x, int y) { + public boolean isBusyCell(int x, int y) { for (Block cell : block) { if (cell.isInBlock(x, y)) return true; @@ -191,28 +190,28 @@ public class Map { return false; } - boolean isCellMoveTo(int x, int y) { + public boolean isCellMoveTo(int x, int y) { for (EventMoveToCell cell : moveToCells) - if (x == cell.getX() && y == cell.getY() && cell.getClass().getName().equals("EventMoveToCell")) + if (x == cell.getX() && y == cell.getY() && cell.getClass().getName().equals("ruscz.game.gameOfProd.Cells.EventMoveToCell")) return true; return false; } - boolean isCellEvent(int x, int y) { + public boolean isCellEvent(int x, int y) { for (InteractionCell cell : eventCells) - if (x == cell.getX() && y == cell.getY() && cell.getClass().getName().equals("InteractionCell")) + if (x == cell.getX() && y == cell.getY() && cell.getClass().getName().equals("ruscz.game.gameOfProd.Cells.InteractionCell")) return true; return false; } - EventMoveToCell findEventByXY(int x, int y) { + public EventMoveToCell findEventByXY(int x, int y) { for (EventMoveToCell cell : moveToCells) if (x == cell.getX() && y == cell.getY()) return cell; return moveToCells.getFirst(); } - InteractionCell findInteractionByXY(int x, int y, int directionSight) { + public InteractionCell findInteractionByXY(int x, int y, int directionSight) { switch (directionSight) { case 1: x--; diff --git a/src/main/java/ruscz/game/gameOfProd/Map/MapManager.java b/src/main/java/ruscz/game/gameOfProd/Map/MapManager.java new file mode 100644 index 0000000..bd4564f --- /dev/null +++ b/src/main/java/ruscz/game/gameOfProd/Map/MapManager.java @@ -0,0 +1,19 @@ +package ruscz.game.gameOfProd.Map; + +import ruscz.game.gameOfProd.Map.Map; +import ruscz.game.gameOfProd.Windows.WindowOfFreeMove; + +import java.util.LinkedList; + +public class MapManager { + WindowOfFreeMove window; + LinkedList maps; + Map actualMap; + + public MapManager(WindowOfFreeMove window){ + this.window = window; + } + + + +} diff --git a/src/main/java/WindowOfFreeMove.java b/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfFreeMove.java similarity index 84% rename from src/main/java/WindowOfFreeMove.java rename to src/main/java/ruscz/game/gameOfProd/Windows/WindowOfFreeMove.java index d34d277..440d250 100644 --- a/src/main/java/WindowOfFreeMove.java +++ b/src/main/java/ruscz/game/gameOfProd/Windows/WindowOfFreeMove.java @@ -1,3 +1,11 @@ +package ruscz.game.gameOfProd.Windows; +import ruscz.game.gameOfProd.Cells.Cell; +import ruscz.game.gameOfProd.Cells.EventMoveToCell; +import ruscz.game.gameOfProd.Cells.InteractionCell; +import ruscz.game.gameOfProd.Dialog.Dialog; +import ruscz.game.gameOfProd.Dialog.DialogBar; +import ruscz.game.gameOfProd.Map.Map; + import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; @@ -6,19 +14,19 @@ import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; public class WindowOfFreeMove extends JFrame { - static final int CELL_SIZE = 40; - static final int CANVAS_WIDTH = 10; - static final int CANVAS_HEIGHT = 10; + public static final int CELL_SIZE = 40; + public static final int CANVAS_WIDTH = 25; + public static final int CANVAS_HEIGHT = 25; private static boolean canPersonMove; private static int nextMove; private static boolean isReadyToPaint; - static final int KEY_LEFT = 37; - static final int KEY_UP = 38; - static final int KEY_RIGHT = 39; - static final int KEY_DOWN = 40; - static final int KEY_EVENT = 69; + public static final int KEY_LEFT = 37; + public static final int KEY_UP = 38; + public static final int KEY_RIGHT = 39; + public static final int KEY_DOWN = 40; + public static final int KEY_EVENT = 69; private Canvas canvas; private DialogBar dialogBar; @@ -164,36 +172,12 @@ public class WindowOfFreeMove extends JFrame { map.createMap(); isReadyToPaint = true; canvas.repaint(); -// -// lp.remove(dialogBar); -// -// -// JPanel jf = new JPanel() { -// Font f = new Font("Times New Roman", Font.ITALIC, 50); -// -// @Override -// public void paint(Graphics g) { -// super.paint(g); -// g.setColor(Color.green); -// g.setFont(f); -// g.drawString("> Test", 10, 50); -// } -// }; -// -// jf.setBounds(0, WindowOfFreeMove.CELL_SIZE * WindowOfFreeMove.CANVAS_HEIGHT * 3 / 4, WindowOfFreeMove.CELL_SIZE * WindowOfFreeMove.CANVAS_WIDTH, WindowOfFreeMove.CELL_SIZE * WindowOfFreeMove.CANVAS_HEIGHT / 4); -// jf.setBackground(Color.BLACK); -// jf.setVisible(false); -// -// setDialogBar(jf); -// dialogBar.setVisible(true); - //setCanPersonMove(false); -// lp.add(jf, JLayeredPane.POPUP_LAYER); timer = new Timer(10, new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { map.getPerson().move(); - canvas.repaint(new Rectangle(CELL_SIZE, CELL_SIZE, CELL_SIZE * 8, CELL_SIZE * 8)); + canvas.repaint(); } }); timer.start();