Structure
This commit is contained in:
parent
0c16b87dd1
commit
59c444d162
@ -1,3 +1,6 @@
|
||||
import ruscz.game.gameOfProd.Map.MapManager;
|
||||
import ruscz.game.gameOfProd.Windows.WindowOfFreeMove;
|
||||
|
||||
public class Game {
|
||||
private MapManager mm;
|
||||
|
||||
|
||||
@ -1,14 +0,0 @@
|
||||
import java.util.LinkedList;
|
||||
|
||||
public class MapManager {
|
||||
WindowOfFreeMove window;
|
||||
LinkedList<Map> maps;
|
||||
Map actualMap;
|
||||
|
||||
MapManager(WindowOfFreeMove window){
|
||||
this.window = window;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -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 {
|
||||
@ -1,3 +1,5 @@
|
||||
package ruscz.game.gameOfProd.Cells;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class Cell {
|
||||
@ -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 {
|
||||
@ -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);
|
||||
@ -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;
|
||||
@ -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 {
|
||||
@ -1,3 +1,5 @@
|
||||
package ruscz.game.gameOfProd.Cells;
|
||||
|
||||
public enum TypeOfCell {
|
||||
BLOCK, EMPTY, MOVETO, EVENT, SPAWNPOINT;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -1,3 +1,7 @@
|
||||
package ruscz.game.gameOfProd.Dialog;
|
||||
|
||||
import ruscz.game.gameOfProd.Image.ImageDialog;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
@ -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();
|
||||
}
|
||||
@ -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();
|
||||
}
|
||||
@ -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();
|
||||
}
|
||||
@ -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<EventMoveToCell>();
|
||||
@ -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--;
|
||||
19
src/main/java/ruscz/game/gameOfProd/Map/MapManager.java
Normal file
19
src/main/java/ruscz/game/gameOfProd/Map/MapManager.java
Normal file
@ -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<Map> maps;
|
||||
Map actualMap;
|
||||
|
||||
public MapManager(WindowOfFreeMove window){
|
||||
this.window = window;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -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();
|
||||
Loading…
x
Reference in New Issue
Block a user